]> granicus.if.org Git - yasm/commitdiff
Changed gas parser to only pass the first cpp line marker onto the debugging module.
authorpaulbarker <paulbarker@localhost>
Sun, 9 Sep 2007 11:51:08 +0000 (11:51 -0000)
committerpaulbarker <paulbarker@localhost>
Sun, 9 Sep 2007 11:51:08 +0000 (11:51 -0000)
svn path=/branches/multiarch/; revision=1935

modules/parsers/gas/gas-parse.c
modules/parsers/gas/gas-parser.c
modules/parsers/gas/gas-parser.h

index 027de7db99e288ea12b7d3f6be7ce792075ba118..2c402f15b9a734dafde1125f2d41e3a8a591854b 100644 (file)
@@ -86,7 +86,7 @@ get_peek_token(yasm_parser_gas *parser_gas)
 {
     char savech = parser_gas->tokch;
     if (parser_gas->peek_token != NONE)
-        yasm_internal_error(N_("only can have one token of lookahead"));
+        yasm_internal_error(N_("can only have one token of lookahead"));
     parser_gas->peek_token =
         gas_parser_lex(&parser_gas->peek_tokval, parser_gas);
     parser_gas->peek_tokch = parser_gas->tokch;
@@ -324,14 +324,22 @@ cpp_line_marker(yasm_parser_gas *parser_gas)
     /* Set linemap. */
     yasm_linemap_set(parser_gas->linemap, filename, line, 1);
 
-    /* Pass change along to debug format */
-    yasm_vps_initialize(&vps);
-    vp = yasm_vp_create_string(NULL, filename);
-    yasm_vps_append(&vps, vp);
+    /*
+        The first line marker in the file (which should be on the first line
+        of the file) will give us the name of the source file. This information
+        needs to be passed on to the debug format module.
+    */
+    if (parser_gas->seen_line_marker == 0) {
+        parser_gas->seen_line_marker = 1;
 
-    yasm_object_directive(p_object, ".file", "gas", &vps, NULL, cur_line);
+        yasm_vps_initialize(&vps);
+        vp = yasm_vp_create_string(NULL, filename);
+        yasm_vps_append(&vps, vp);
 
-    yasm_vps_delete(&vps);
+        yasm_object_directive(p_object, ".file", "gas", &vps, NULL, cur_line);
+
+        yasm_vps_delete(&vps);
+    }
 
     /* Skip flags. */
     while (1) {
index 6d8aa998cec0a7f0ffff40f64151b1891178a2b9..521851cdd8ce93de0157f4ac2b0eadd8db344c96 100644 (file)
@@ -52,6 +52,7 @@ gas_parser_do_parse(yasm_object *object, yasm_preproc *pp,
     parser_gas.dir_fileline = 0;
     parser_gas.dir_file = NULL;
     parser_gas.dir_line = 0;
+    parser_gas.seen_line_marker = 0;
 
     parser_gas.preproc = pp;
     parser_gas.errwarns = errwarns;
index bfae0a9da1a45fd9ed61812b96f16ac462afdd36..eece2a23f8f65d1fc96f24fe8fab26fba1eeed14 100644 (file)
@@ -107,6 +107,9 @@ typedef struct yasm_parser_gas {
     /*@null@*/ char *dir_file;
     unsigned long dir_line;
 
+    /* Have we seen a line marker? */
+    int seen_line_marker;
+
     /*@dependent@*/ yasm_preproc *preproc;
     /*@dependent@*/ yasm_errwarns *errwarns;