More linting in src

This commit is contained in:
Jasmine Iwanek
2023-08-21 20:25:33 -04:00
parent bacf8deae3
commit b8c4dee3bf
17 changed files with 193 additions and 161 deletions

View File

@@ -266,22 +266,22 @@ ini_close(ini_t ini)
static int
ini_detect_bom(const char *fn)
{
FILE *f;
FILE *fp;
unsigned char bom[4] = { 0, 0, 0, 0 };
#if defined(ANSI_CFG) || !defined(_WIN32)
f = plat_fopen(fn, "rt");
fp = plat_fopen(fn, "rt");
#else
f = plat_fopen(fn, "rt, ccs=UTF-8");
fp = plat_fopen(fn, "rt, ccs=UTF-8");
#endif
if (f == NULL)
if (fp == NULL)
return 0;
(void) !fread(bom, 1, 3, f);
(void) !fread(bom, 1, 3, fp);
if (bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF) {
fclose(f);
fclose(fp);
return 1;
}
fclose(f);
fclose(fp);
return 0;
}
@@ -323,16 +323,16 @@ ini_read(const char *fn)
int c;
int d;
int bom;
FILE *f;
FILE *fp;
list_t *head;
bom = ini_detect_bom(fn);
#if defined(ANSI_CFG) || !defined(_WIN32)
f = plat_fopen(fn, "rt");
fp = plat_fopen(fn, "rt");
#else
f = plat_fopen(fn, "rt, ccs=UTF-8");
fp = plat_fopen(fn, "rt, ccs=UTF-8");
#endif
if (f == NULL)
if (fp == NULL)
return NULL;
head = malloc(sizeof(list_t));
@@ -343,16 +343,16 @@ ini_read(const char *fn)
list_add(&sec->list, head);
if (bom)
fseek(f, 3, SEEK_SET);
fseek(fp, 3, SEEK_SET);
while (1) {
memset(buff, 0x00, sizeof(buff));
#ifdef __HAIKU__
ini_fgetws(buff, sizeof_w(buff), f);
#else
(void) !fgetws(buff, sizeof_w(buff), f);
(void) !fgetws(buff, sizeof_w(buff), fp);
#endif
if (feof(f))
if (feof(fp))
break;
/* Make sure there are no stray newlines or hard-returns in there. */
@@ -436,7 +436,7 @@ ini_read(const char *fn)
list_add(&ne->list, &sec->entry_head);
}
(void) fclose(f);
(void) fclose(fp);
return (ini_t) head;
}
@@ -448,7 +448,7 @@ ini_write(ini_t ini, const char *fn)
wchar_t wtemp[512];
list_t *list = (list_t *) ini;
section_t *sec;
FILE *f;
FILE *fp;
int fl = 0;
if (list == NULL)
@@ -457,11 +457,11 @@ ini_write(ini_t ini, const char *fn)
sec = (section_t *) list->next;
#if defined(ANSI_CFG) || !defined(_WIN32)
f = plat_fopen(fn, "wt");
fp = plat_fopen(fn, "wt");
#else
f = plat_fopen(fn, "wt, ccs=UTF-8");
fp = plat_fopen(fn, "wt, ccs=UTF-8");
#endif
if (f == NULL)
if (fp == NULL)
return;
while (sec != NULL) {
@@ -470,9 +470,9 @@ ini_write(ini_t ini, const char *fn)
if (sec->name[0]) {
mbstowcs(wtemp, sec->name, strlen(sec->name) + 1);
if (fl)
fwprintf(f, L"\n[%ls]\n", wtemp);
fwprintf(fp, L"\n[%ls]\n", wtemp);
else
fwprintf(f, L"[%ls]\n", wtemp);
fwprintf(fp, L"[%ls]\n", wtemp);
fl++;
}
@@ -481,9 +481,9 @@ ini_write(ini_t ini, const char *fn)
if (ent->name[0] != '\0') {
mbstowcs(wtemp, ent->name, 128);
if (ent->wdata[0] == L'\0')
fwprintf(f, L"%ls = \n", wtemp);
fwprintf(fp, L"%ls = \n", wtemp);
else
fwprintf(f, L"%ls = %ls\n", wtemp, ent->wdata);
fwprintf(fp, L"%ls = %ls\n", wtemp, ent->wdata);
fl++;
}
@@ -493,7 +493,7 @@ ini_write(ini_t ini, const char *fn)
sec = (section_t *) sec->list.next;
}
(void) fclose(f);
(void) fclose(fp);
}
ini_t