Skip to content

Commit 4a13358

Browse files
committed
Use internal warn for xy.h
1 parent 8833eb9 commit 4a13358

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/xy.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ xy =
145145
#define xy_cant_be_null(p) if(!p) xy_throw("This pointer can't be null")
146146

147147

148+
static inline void
149+
_xy_internal_warn (char *str)
150+
{
151+
fprintf (stderr, "[xy.h] %s\n", str);
152+
}
148153

149154
static void _xy_print_int (int n) {printf ("%d", n);}
150155
static void _xy_print_long (long n) {printf ("%ld", n);}
@@ -375,7 +380,7 @@ xy_strcat (unsigned int count, ...)
375380
}
376381
if (NULL == ret)
377382
{
378-
fprintf (stderr, "xy.h: No availble memory!");
383+
_xy_internal_warn ("xy_strcat(): No availble memory to allocate!");
379384
return NULL;
380385
}
381386
strcpy (cur, str);
@@ -401,7 +406,7 @@ xy_strdup (const char *str)
401406
{
402407
if (!str)
403408
{
404-
fprintf (stderr, "xy.h: xy_strdup() called with NULL!\n");
409+
_xy_internal_warn ("xy_strdup(): called with NULL!");
405410
return NULL;
406411
}
407412

@@ -963,7 +968,7 @@ xy_run_iter_lines (const char *cmd, unsigned long n, bool (*func) (const char
963968
FILE *stream = popen (cmd, "r");
964969
if (stream == NULL)
965970
{
966-
fprintf (stderr, "xy: 命令执行失败\n");
971+
_xy_internal_warn ("xy_run_iter_lines(): popen() failed");
967972
return NULL;
968973
}
969974

@@ -1028,7 +1033,7 @@ xy_run_get_stdout (const char *cmd, char **output)
10281033
FILE *stream = popen (cmd, "r");
10291034
if (stream == NULL)
10301035
{
1031-
fprintf (stderr, "xy: 命令执行失败\n");
1036+
_xy_internal_warn ("xy_run_get_stdout(): popen() failed");
10321037
return -1;
10331038
}
10341039

0 commit comments

Comments
 (0)