commit 90c70c6eab5c66f7c7d7339013abc49dc785f9cb
parent 4bb1e0787b0026d1ee123381af348a9b1605db06
Auteur: Selve <selve@asteride.xyz>
Date: Fri, 22 Mar 2024 16:37:33 -0400
refactorisation mineure
Diffstat:
4 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
@@ -10,7 +10,7 @@ DOS_PO = po
DOS_MAN = man
CC = cc
-COPTS_SPCL = -O2 -DNDEBUG
+#COPTS_SPCL = -O2 -DNDEBUG
COPTS = -Wall -Wextra -Werror -Wpedantic -Wno-implicit-fallthrough \
--std=c89 ${COPTS_SPCL}
CPPOPTS = -I${INC_DOS} -DI18N_DOMAINE=\"aplat\" -DI18N_DOS=\"${I18N_DOS}\"
@@ -28,8 +28,8 @@ FCH_MO != find ${DOS_PO} -name '*.po' | sed 's/\.po$$/\.mo/'
all: aplat traductions
-aplat: aplat.o tampon.o
- ${CC} ${COPTS} ${LDOPTS} -o "$@" aplat.o tampon.o ${LIBS}
+aplat: aplat.o tampon.o general.o
+ ${CC} ${COPTS} ${LDOPTS} -o "$@" aplat.o tampon.o general.o ${LIBS}
traductions: ${FCH_MO}
diff --git a/aplat.c b/aplat.c
@@ -2,16 +2,15 @@
#include <stdio.h>
#ifdef __OpenBSD__
- #include <unistd.h>
+#include <unistd.h>
#endif
#include <libintl.h>
#include <locale.h>
+#include "general.h"
#include "tampon.h"
-#define VERSION "2.0 (?\?\?)"
-
#define DRAP_OUV 01 /* parenthèse ouvrante */
#define DRAP_FRM 02 /* parenthèse fermante */
@@ -23,8 +22,6 @@
#define JT_FRM 1 /* parenthèse fermante */
#define JT_ATM 2 /* atome */
-#define _(c) gettext(c)
-
static void utilisation(void);
static int aplatir(FILE *);
static int obt_jeton(FILE *, struct tampon *);
@@ -43,8 +40,7 @@ struct tampon pile; /* pile */
int
main(int argc, char **argv)
{
- if ((prog_nom = argv[0]) == NULL || prog_nom[0] == '\0')
- prog_nom = "aplat";
+ prog_nom = trouv_prog_nom(argv, "aplat");
setlocale(LC_ALL, "");
bindtextdomain(I18N_DOMAINE, I18N_DOS);
diff --git a/general.c b/general.c
@@ -0,0 +1,14 @@
+#include "stdlib.h"
+
+#include "general.h"
+
+char *
+trouv_prog_nom(char **argv, char *nom)
+{
+ char *n;
+
+ if ((n = argv[0]) == NULL || n[0] == '\0')
+ return nom;
+ return n;
+
+}
diff --git a/general.h b/general.h
@@ -0,0 +1,9 @@
+#ifndef GENERAL_H
+#define GENERAL_H
+
+#define VERSION "2.0 (?\?\?)"
+#define _(c) gettext(c)
+
+char *trouv_prog_nom(char **, char *);
+
+#endif