Subversion Repositories SvarDOS

Rev

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

Rev 2123 Rev 2143
Line 278... Line 278...
278
  fname[strlen(fname) - 6] = (char)tolower( l->id[0] );
278
  fname[strlen(fname) - 6] = (char)tolower( l->id[0] );
279
  fname[strlen(fname) - 5] = (char)tolower( l->id[1] );
279
  fname[strlen(fname) - 5] = (char)tolower( l->id[1] );
280
 
280
 
281
  fd = fopen(fname, "rb");
281
  fd = fopen(fname, "rb");
282
  if (fd == NULL) {
282
  if (fd == NULL) {
283
    printf("ERROR: FAILED TO OPEN '%s'\r\n", fname);
283
    printf("ERROR: FAILED TO OPEN '%s'\n", fname);
284
    return(0);
284
    return(0);
285
  }
285
  }
286
 
286
 
287
  for (linecount = 1;; linecount++) {
287
  for (linecount = 1;; linecount++) {
288
    linelen = readl(linebuf, sizeof(linebuf), fd);
288
    linelen = readl(linebuf, sizeof(linebuf), fd);
Line 295... Line 295...
295
    /* read id and get ptr to actual string ("1.15:string") */
295
    /* read id and get ptr to actual string ("1.15:string") */
296
    ptr = parseline(&id, linebuf);
296
    ptr = parseline(&id, linebuf);
297
 
297
 
298
    /* handle malformed lines */
298
    /* handle malformed lines */
299
    if (ptr == NULL) {
299
    if (ptr == NULL) {
300
      printf("WARNING: %s[#%u] is malformed (linelen = %u):\r\n", fname, linecount, linelen);
300
      printf("WARNING: %s[#%u] is malformed (linelen = %u):\n", fname, linecount, linelen);
301
      puts(linebuf);
301
      puts(linebuf);
302
      continue;
302
      continue;
303
    }
303
    }
304
 
304
 
305
    /* ignore empty strings (but emit a warning) */
305
    /* ignore empty strings (but emit a warning) */
306
    if (ptr[0] == 0) {
306
    if (ptr[0] == 0) {
307
      printf("WARNING: %s[#%u] ignoring empty string %u.%u\r\n", fname, linecount, id >> 8, id & 0xff);
307
      printf("WARNING: %s[#%u] ignoring empty string %u.%u\n", fname, linecount, id >> 8, id & 0xff);
308
      continue;
308
      continue;
309
    }
309
    }
310
 
310
 
311
    /* warn about dirty lines */
311
    /* warn about dirty lines */
312
    if (linebuf[0] == '?') {
312
    if (linebuf[0] == '?') {
313
      printf("WARNING: %s[#%u] string id %u.%u is flagged as 'dirty'\r\n", fname, linecount, id >> 8, id & 0xff);
313
      printf("WARNING: %s[#%u] string id %u.%u is flagged as 'dirty'\n", fname, linecount, id >> 8, id & 0xff);
314
    }
314
    }
315
 
315
 
316
    /* add the string contained in current line, if conditions are met */
316
    /* add the string contained in current line, if conditions are met */
317
    if (!svl_find(l, id)) {
317
    if (!svl_find(l, id)) {
318
      if ((refl == NULL) || (svl_find(refl, id))) {
318
      if ((refl == NULL) || (svl_find(refl, id))) {
Line 323... Line 323...
323
        }
323
        }
324
        if (id >= maxid) {
324
        if (id >= maxid) {
325
          maxid = id;
325
          maxid = id;
326
          maxid_line = linecount;
326
          maxid_line = linecount;
327
        } else {
327
        } else {
328
          printf("WARNING:%s[#%u] file unsorted - line %u has higher id %u.%u\r\n", fname, linecount, maxid_line, maxid >> 8, maxid & 0xff);
328
          printf("WARNING:%s[#%u] file unsorted - line %u has higher id %u.%u\n", fname, linecount, maxid_line, maxid >> 8, maxid & 0xff);
329
        }
329
        }
330
      } else {
330
      } else {
331
        printf("WARNING: %s[#%u] has an invalid id (%u.%u not present in ref lang)\r\n", fname, linecount, id >> 8, id & 0xff);
331
        printf("WARNING: %s[#%u] has an invalid id (%u.%u not present in ref lang)\n", fname, linecount, id >> 8, id & 0xff);
332
      }
332
      }
333
    } else {
333
    } else {
334
      printf("WARNING: %s[#%u] has a duplicated id (%u.%u)\r\n", fname, linecount, id >> 8, id & 0xff);
334
      printf("WARNING: %s[#%u] has a duplicated id (%u.%u)\n", fname, linecount, id >> 8, id & 0xff);
335
    }
335
    }
336
  }
336
  }
337
 
337
 
338
  fclose(fd);
338
  fclose(fd);
339
 
339
 
340
  /* if reflang provided, pull missing strings from it */
340
  /* if reflang provided, pull missing strings from it */
341
  if (refl != NULL) {
341
  if (refl != NULL) {
342
    for (i = 0; i < refl->num_strings; i++) {
342
    for (i = 0; i < refl->num_strings; i++) {
343
      id = refl->dict[i].id;
343
      id = refl->dict[i].id;
344
      if (!svl_find(l, id)) {
344
      if (!svl_find(l, id)) {
345
        printf("WARNING: %s is missing string %u.%u (pulled from ref lang)\r\n", fname, id >> 8, id & 0xff);
345
        printf("WARNING: %s is missing string %u.%u (pulled from ref lang)\n", fname, id >> 8, id & 0xff);
346
        if (!svl_add_str(l, id, refl->strings + refl->dict[i].offset)) {
346
        if (!svl_add_str(l, id, refl->strings + refl->dict[i].offset)) {
347
          fprintf(stderr, "ERROR: %s[#%u] output size limit exceeded\r\n", fname, linecount);
347
          fprintf(stderr, "ERROR: %s[#%u] output size limit exceeded\r\n", fname, linecount);
348
          return(0);
348
          return(0);
349
        }
349
        }
350
      }
350
      }