Skip to content
Snippets Groups Projects
Commit 92dd34ed authored by rswindell's avatar rswindell
Browse files

Created strListPush and strListPop convenience macros.

Removed pad argument from strListReadFile().
parent c2440435
No related branches found
No related tags found
No related merge requests found
......@@ -583,7 +583,7 @@ str_list_t iniReadFile(FILE* fp)
rewind(fp);
list = strListReadFile(fp, NULL, INI_MAX_LINE_LEN, FALSE /* pad */);
list = strListReadFile(fp, NULL, INI_MAX_LINE_LEN);
if(list!=NULL) {
/* truncate the white-space off end of strings */
for(i=0; list[i]!=NULL; i++)
......
......@@ -321,7 +321,7 @@ void strListFree(str_list_t* list)
}
}
str_list_t strListReadFile(FILE* fp, str_list_t* lp, size_t max_line_len, BOOL pad)
str_list_t strListReadFile(FILE* fp, str_list_t* lp, size_t max_line_len)
{
char* buf=NULL;
size_t count;
......@@ -343,11 +343,7 @@ str_list_t strListReadFile(FILE* fp, str_list_t* lp, size_t max_line_len, BOOL p
if(fgets(buf,max_line_len+1,fp)==NULL)
break;
if(pad) {
str_list_append(lp, buf, count++);
buf=NULL;
} else
strListAppend(lp, buf, count++);
strListAppend(lp, buf, count++);
}
if(buf!=NULL)
......
......@@ -80,6 +80,10 @@ BOOL strListDelete(str_list_t* list, size_t index);
/* Replace a string at a specific index */
char* strListReplace(const str_list_t list, size_t index, const char* str);
/* Convenience macros for pushing, popping strings (LIFO stack) */
#define strListPush(list, str) strListAppend(list, str, STR_LIST_LAST_INDEX)
#define strListPop(list) strListRemove(list, STR_LIST_LAST_INDEX)
/* Add to an exiting or new string list by splitting specified string (str) */
/* into multiple strings, separated by one of the delimit characters */
str_list_t strListSplit(str_list_t* list, char* str, const char* delimit);
......@@ -107,7 +111,7 @@ void strListSortAlphaCaseReverse(str_list_t list);
/* Read lines from file appending each line to string list */
/* Pass NULL list to have list allocated for you */
str_list_t strListReadFile(FILE* fp, str_list_t* list, size_t max_line_len, BOOL pad);
str_list_t strListReadFile(FILE* fp, str_list_t* list, size_t max_line_len);
/* Write to file (fp) each string in the list, optionally separated by separator (e.g. "\n") */
size_t strListWriteFile(FILE* fp, const str_list_t list, const char* separator);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment