Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Ajout pour LC_TEXT_EN
- void locale_init2(const char* filename)
- {
- FILE* fp = fopen(filename, "rb");
- char* buf;
- if (!fp) return;
- fseek(fp, 0L, SEEK_END);
- int i = ftell(fp);
- fseek(fp, 0L, SEEK_SET);
- i++;
- buf = M2_NEW char[i];
- memset(buf, 0, i);
- fread(buf, i - 1, sizeof(char), fp);
- fclose(fp);
- const char* tmp;
- const char* end;
- char* strings[NUM_LOCALES];
- if (!buf)
- {
- sys_err("locale_read: no file %s", filename);
- exit(1);
- }
- tmp = buf;
- do
- {
- for (i = 0; i < NUM_LOCALES; i++)
- strings[i] = NULL;
- if (*tmp == '"')
- {
- for (i = 0; i < NUM_LOCALES; i++)
- {
- if (!(end = quote_find_end(tmp)))
- break;
- strings[i] = locale_convert(tmp, end - tmp);
- tmp = ++end;
- while (*tmp == '\n' || *tmp == '\r' || *tmp == ' ') tmp++;
- if (i + 1 == NUM_LOCALES)
- break;
- if (*tmp != '"')
- {
- sys_err("locale_init: invalid format filename %s", filename);
- break;
- }
- }
- if (strings[0] == NULL || strings[1] == NULL)
- break;
- locale_add((const char**)strings);
- for (i = 0; i < NUM_LOCALES; i++)
- if (strings[i])
- M2_DELETE_ARRAY(strings[i]);
- }
- else
- {
- tmp = strchr(tmp, '\n');
- if (tmp)
- tmp++;
- }
- } while (tmp && *tmp);
- M2_DELETE_ARRAY(buf);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement