mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-17 20:01:36 +02:00
eeshow/fig.c (fig_init): use getline instead of fgets
This commit is contained in:
parent
37351bf8bc
commit
7d72a28c31
@ -237,13 +237,14 @@ static bool apply_vars(char *buf, int n_vars, const char **vars)
|
|||||||
|
|
||||||
static void *fig_init(int argc, char *const *argv)
|
static void *fig_init(int argc, char *const *argv)
|
||||||
{
|
{
|
||||||
|
static char *buf = NULL;
|
||||||
|
static size_t n = 0;
|
||||||
const char *template = NULL;
|
const char *template = NULL;
|
||||||
const char **vars = NULL;
|
const char **vars = NULL;
|
||||||
int n_vars = 0;
|
int n_vars = 0;
|
||||||
char c;
|
char c;
|
||||||
int arg;
|
int arg;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char buf[1000];
|
|
||||||
int lines_to_colors = 8;
|
int lines_to_colors = 8;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "t:")) != EOF)
|
while ((c = getopt(argc, argv, "t:")) != EOF)
|
||||||
@ -272,7 +273,7 @@ static void *fig_init(int argc, char *const *argv)
|
|||||||
file = fopen(template, "r");
|
file = fopen(template, "r");
|
||||||
if (!file)
|
if (!file)
|
||||||
diag_pfatal(template);
|
diag_pfatal(template);
|
||||||
while (fgets(buf, sizeof(buf), file)) {
|
while (getline(&buf, &n, file) > 0) {
|
||||||
while (apply_vars(buf, n_vars, vars));
|
while (apply_vars(buf, n_vars, vars));
|
||||||
printf("%s", buf);
|
printf("%s", buf);
|
||||||
if (*buf == '#')
|
if (*buf == '#')
|
||||||
|
Loading…
Reference in New Issue
Block a user