summaryrefslogtreecommitdiff
path: root/setedit/internac/emptymsg.cc
blob: d59aea44bc14015f1bab13b07ffb4945c7bf7d1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**[txh]********************************************************************

  Copyright (c) 2001 by Salvador E. Tropea (SET) set@ieee.org
  Covered by the GPL license, you should get a copy of it with this file.

  Description:
  This simple program searchs for empty or fuzzy entries in a .po file and
generates a report in the same style used by GNU tools. Running it from
setedit you'll be able to jump forward and backward in the report using
Alt+F7/F8 keys.
  
***************************************************************************/

#include <stdio.h>
#include <string.h>
#include <ctype.h>

typedef unsigned char uchar;

int main(int argc, char *argv[])
{
 if (argc<2)
   {
    printf("Empty message searcher. Copyright (c) 2001 by Salvador E. Tropea <set@ieee.org>\n");
    printf("Covered by the GPL license, you should get a copy of it with this file.");
    printf("\nUse: emptymsg files...\n");
    return 1;
   }
 int i;
 for (i=1; i<argc; i++)
    {
     FILE *f=fopen(argv[i],"rt");
     if (!f)
       {
        fprintf(stderr,"Failed to open %s\n",argv[i]);
        continue;
       }
    
     char b[200],*s,NextMsgStrFuzzy=0;
     int line=0;
     while (!feof(f))
       {
        if (fgets(b,199,f))
          {
           line++;
           if (strncmp(b,"msgstr",6)==0)
             {
              if (NextMsgStrFuzzy)
                {
                 printf("%s:%d: fuzzy\n",argv[i],line);
                 NextMsgStrFuzzy=0;
                }
              else
                {
                 for (s=b+6; *s && isspace((uchar)*s); s++);
                 if (*s && *s=='"' && s[1]=='"')
                   {// Candidate
                    if (fgets(b,199,f))
                      {
                       if (b[0]!='"')
                          printf("%s:%d: empty\n",argv[i],line);
                       line++;
                      }
                   }
                }
             }
           else
             if (strncmp(b,"#, fuzzy",8)==0)
                NextMsgStrFuzzy=1;
          }
       }
     fclose(f);
    }
 return 0;
}