]> git.draconx.ca Git - gob-dx.git/blobdiff - src/out.c
Release 0.92.1
[gob-dx.git] / src / out.c
index 3183635acbaed6cada22c41e6e0c8c03c4e527cc..3fdf7cf35df9b1847c192cda319d01a910ccaf8e 100644 (file)
--- a/src/out.c
+++ b/src/out.c
@@ -6,12 +6,19 @@
 
 extern FILE *out;
 extern FILE *outh;
+extern FILE *outph;
+
+extern gboolean for_cpp;
 
 extern char *filename;
 extern char *filebase;
 
 int outline = 1;
+static gboolean in_out = TRUE;
 int outhline = 1;
+static gboolean in_outh = TRUE;
+int outphline = 1;
+static gboolean in_outph = TRUE;
 
 static int
 strchrcnt(char *s, char c)
@@ -37,6 +44,8 @@ out_printf(FILE *fp,char *format,...)
                outline += strchrcnt(s,'\n');
        else if(fp == outh)
                outhline += strchrcnt(s,'\n');
+       else if(fp == outph)
+               outphline += strchrcnt(s,'\n');
        else
                g_assert_not_reached();
 
@@ -47,11 +56,16 @@ out_printf(FILE *fp,char *format,...)
 void
 out_addline_infile(FILE *fp, int line)
 {
-       if(fp == out)
+       if(fp == out) {
                outline++;
-       else if(fp == outh)
+               in_out = FALSE;
+       } else if(fp == outh) {
                outhline++;
-       else
+               in_outh = FALSE;
+       } else if(fp == outph) {
+               outphline++;
+               in_outph = FALSE;
+       } else
                g_assert_not_reached();
 
        fprintf(fp,"#line %d \"%s\"\n",line,filename);
@@ -61,12 +75,23 @@ void
 out_addline_outfile(FILE *fp)
 {
        if(fp == out) {
+               if(in_out) return;
                outline++;
-               fprintf(fp,"#line %d \"%s.c\"\n",outline,filebase);
+               if(!for_cpp)
+                       fprintf(fp,"#line %d \"%s.c\"\n",outline,filebase);
+               else
+                       fprintf(fp,"#line %d \"%s.cc\"\n",outline,filebase);
+               in_out = TRUE;
        } else if(fp == outh) {
+               if(in_outh) return;
                outhline++;
                fprintf(fp,"#line %d \"%s.h\"\n",outhline,filebase);
+               in_outh = TRUE;
+       } else if(fp == outph) {
+               if(in_outph) return;
+               outphline++;
+               fprintf(fp,"#line %d \"%s-private.h\"\n",outphline,filebase);
+               in_outph = TRUE;
        } else
                g_assert_not_reached();
-
 }