]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
isc_lex_setsourcename(), for use when lexing buffers or streams
authorBrian Wellington <source@isc.org>
Thu, 21 Feb 2002 00:44:16 +0000 (00:44 +0000)
committerBrian Wellington <source@isc.org>
Thu, 21 Feb 2002 00:44:16 +0000 (00:44 +0000)
lib/isc/include/isc/lex.h
lib/isc/lex.c

index 13ad7186a9c49efd39fcf3ceed76d0c22e01e9ba..2251235d339d8361106a753b06a2c4d5d09da083 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: lex.h,v 1.28 2002/02/20 03:35:33 marka Exp $ */
+/* $Id: lex.h,v 1.29 2002/02/21 00:44:16 bwelling Exp $ */
 
 #ifndef ISC_LEX_H
 #define ISC_LEX_H 1
@@ -376,6 +376,21 @@ isc_lex_getsourceline(isc_lex_t *lex);
  *     Current line number or 0 if no current source.
  */
 
+isc_result_t
+isc_lex_setsourcename(isc_lex_t *lex, const char *name);
+/*
+ * Assigns a new name to the input source.
+ *
+ * Requires:
+ *
+ *     'lex' is a valid lexer.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS
+ *     ISC_R_NOMEMORY
+ *     ISC_R_NOTFOUND - there are no sources.
+ */
+
 isc_boolean_t
 isc_lex_isfile(isc_lex_t *lex);
 /*
index 6e1f0407192f67e1c64edb798437efa680735b17..ffc3a4527774804eec4c77ddf96e4afb16c345ce 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: lex.c,v 1.72 2001/12/13 06:13:44 marka Exp $ */
+/* $Id: lex.c,v 1.73 2002/02/21 00:44:14 bwelling Exp $ */
 
 #include <config.h>
 
@@ -869,7 +869,7 @@ isc_lex_getsourcename(isc_lex_t *lex) {
        source = HEAD(lex->sources);
 
        if (source == NULL)
-               return(NULL);
+               return (NULL);
 
        return (source->name);
 }
@@ -882,11 +882,30 @@ isc_lex_getsourceline(isc_lex_t *lex) {
        source = HEAD(lex->sources);
 
        if (source == NULL)
-               return(0);
+               return (0);
 
        return (source->line);
 }
 
+
+isc_result_t
+isc_lex_setsourcename(isc_lex_t *lex, const char *name) {
+       inputsource *source;
+       char *newname;
+
+       REQUIRE(VALID_LEX(lex));
+       source = HEAD(lex->sources);
+
+       if (source == NULL)
+               return(ISC_R_NOTFOUND);
+       newname = isc_mem_strdup(lex->mctx, name);
+       if (newname == NULL)
+               return (ISC_R_NOMEMORY);
+       isc_mem_free(lex->mctx, source->name);
+       source->name = newname;
+       return (ISC_R_SUCCESS);
+}
+
 isc_boolean_t
 isc_lex_isfile(isc_lex_t *lex) {
        inputsource *source;