Made '-' a constant
authorLukas Krickl <lukas@krickl.dev>
Mon, 20 Nov 2023 18:33:25 +0000 (19:33 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 20 Nov 2023 18:33:25 +0000 (19:33 +0100)
include/ulas.h
src/ulas.c

index 0f37c43d8f8768cfa06585b628600dfb63754ed1..2937c394e890e5b5075b852ea199b6467ac5acdd 100644 (file)
@@ -5,6 +5,9 @@
 #include <stdio.h>
 #include <string.h>
 
+// if this is used as a path use stdin or stdout instead
+#define ULAS_STDFILEPATH "-"
+
 #define ULAS_PATHMAX 4096
 #define ULAS_LINEMAX 4096
 #define ULAS_OUTBUFMAX 64
   }
 
 /**
- * Output target files 
+ * Output target files
  */
 
-// input file for source reader 
+// input file for source reader
 extern FILE *ulasin;
-// source code output target 
+// source code output target
 extern FILE *ulasout;
 // error output target
 extern FILE *ulaserr;
-// assembly listing output 
+// assembly listing output
 extern FILE *ulaslstout;
 // symbol list output
 extern FILE *ulassymout;
index 903b739730b76fca8a1d73b062e55c18855711d3..a8b259e3bb97823c6d62aa84b331a4594d5045b3 100644 (file)
@@ -56,7 +56,7 @@ struct ulas_config ulas_cfg_from_env(void) {
 }
 
 FILE *ulas_fopen(const char *path, const char *mode, FILE *stdfile) {
-  if (!path || strncmp(path, "-", 1) == 0) {
+  if (!path || strncmp(path, ULAS_STDFILEPATH, 1) == 0) {
     return stdfile;
   }
   FILE *f = fopen(path, mode);