* If linenum is not NULL, it is incremented by the number of physical lines
* which have been read.
*/
-char *getline_wrapped(FILE *fp, unsigned int *linenum)
+char *freadline_wrapped(FILE *fp, unsigned int *linenum)
{
int size = 256;
int i = 0, n = 0;
ssize_t write_str_safe(int fd, const char *buf, size_t buflen) __attribute__((nonnull(2)));
int read_str_long(int fd, long *value, int base) _must_check_ __attribute__((nonnull(2)));
int read_str_ulong(int fd, unsigned long *value, int base) _must_check_ __attribute__((nonnull(2)));
-char *getline_wrapped(FILE *fp, unsigned int *linenum) __attribute__((nonnull(1)));
+char *freadline_wrapped(FILE *fp, unsigned int *linenum) __attribute__((nonnull(1)));
/* path handling functions */
/* ************************************************************************ */
.out = TESTSUITE_ROOTFS "test-util/alias-correct.txt",
});
-static int test_getline_wrapped(const struct test *t)
+static int test_freadline_wrapped(const struct test *t)
{
- FILE *fp = fopen("/getline_wrapped-input.txt", "re");
+ FILE *fp = fopen("/freadline_wrapped-input.txt", "re");
if (!fp)
return EXIT_FAILURE;
while (!feof(fp) && !ferror(fp)) {
unsigned int num = 0;
- char *s = getline_wrapped(fp, &num);
+ char *s = freadline_wrapped(fp, &num);
if (!s)
break;
puts(s);
fclose(fp);
return EXIT_SUCCESS;
}
-static DEFINE_TEST(test_getline_wrapped,
- .description = "check if getline_wrapped() does the right thing",
+static DEFINE_TEST(test_freadline_wrapped,
+ .description = "check if freadline_wrapped() does the right thing",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-util/",
},
.need_spawn = true,
.output = {
- .out = TESTSUITE_ROOTFS "test-util/getline_wrapped-correct.txt",
+ .out = TESTSUITE_ROOTFS "test-util/freadline_wrapped-correct.txt",
});
static const struct test *tests[] = {
&salias_1,
- &stest_getline_wrapped,
+ &stest_freadline_wrapped,
NULL,
};
return err;
}
- while ((line = getline_wrapped(fp, &linenum)) != NULL) {
+ while ((line = freadline_wrapped(fp, &linenum)) != NULL) {
char *cmd, *saveptr;
if (line[0] == '\0' || line[0] == '#')