Subversion Repositories SvarDOS

Rev

Rev 623 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 623 Rev 639
Line 98... Line 98...
98
 
98
 
99
  return(s + colpos + 1);
99
  return(s + colpos + 1);
100
}
100
}
101
 
101
 
102
 
102
 
-
 
103
/* converts escape sequences like "\n" or "\t" into actual bytes, returns
-
 
104
 * the new length of the string. */
-
 
105
static unsigned short unesc_string(char *linebuff) {
-
 
106
  unsigned short i;
-
 
107
  for (i = 0; linebuff[i] != 0; i++) {
-
 
108
    if (linebuff[i] != '\\') continue;
-
 
109
    strcpy(linebuff + i, linebuff + i + 1);
-
 
110
    if (linebuff[i] == 0) break;
-
 
111
    switch (linebuff[i]) {
-
 
112
      case 'n':
-
 
113
        linebuff[i] = '\n';
-
 
114
        break;
-
 
115
      case 'r':
-
 
116
        linebuff[i] = '\r';
-
 
117
        break;
-
 
118
      case 't':
-
 
119
        linebuff[i] = '\t';
-
 
120
        break;
-
 
121
    }
-
 
122
  }
-
 
123
  return(i);
-
 
124
}
-
 
125
 
-
 
126
 
103
/* opens a CATS-style file and compiles it into a ressources lang block */
127
/* opens a CATS-style file and compiles it into a ressources lang block */
104
static unsigned short gen_langstrings(unsigned char *buff, const char *langid, struct bitmap *b, const struct bitmap *refb, const unsigned char *refblock) {
128
static unsigned short gen_langstrings(unsigned char *buff, const char *langid, struct bitmap *b, const struct bitmap *refb, const unsigned char *refblock) {
105
  unsigned short len = 0, linelen;
129
  unsigned short len = 0, linelen;
106
  FILE *fd;
130
  FILE *fd;
107
  char fname[] = "XX.TXT";
131
  char fname[] = "XX.TXT";
Line 123... Line 147...
123
 
147
 
124
    linelen = readl(linebuf, sizeof(linebuf), fd);
148
    linelen = readl(linebuf, sizeof(linebuf), fd);
125
    if (linelen == 0xffff) break; /* EOF */
149
    if (linelen == 0xffff) break; /* EOF */
126
    if ((linelen == 0) || (linebuf[0] == '#')) continue;
150
    if ((linelen == 0) || (linebuf[0] == '#')) continue;
127
 
151
 
-
 
152
    /* convert escaped chars to actual bytes (\n -> newline, etc) */
-
 
153
    linelen = unesc_string(linebuf);
-
 
154
 
128
    /* read id and get ptr to actual string ("1.15:string") */
155
    /* read id and get ptr to actual string ("1.15:string") */
129
    ptr = parseline(&id, linebuf);
156
    ptr = parseline(&id, linebuf);
130
    if (ptr == NULL) {
157
    if (ptr == NULL) {
131
      printf("ERROR: line #%u of %s is malformed (linelen = %u):\r\n", linecount, fname, linelen);
158
      printf("ERROR: line #%u of %s is malformed (linelen = %u):\r\n", linecount, fname, linelen);
132
      puts(linebuf);
159
      puts(linebuf);