ufold

Прелама сваки UTF-8 улазни ред да стане у задату дужину
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 35bcf93c1160bc47f793ffbedbb2cde44fa0f9ed
родитељ e92bad6391aa2ca8648976a8307ae7b6cc4a2601
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Tue, 20 Jul 2021 10:05:39 +0200

Added version.h.in, moved defs.h to non-generated; added a check

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
M.gitignore | 2+-
Mall.do | 2+-
Adefs.h | 8++++++++
Ddefs.h.in | 11-----------
Mufold.c | 17+++++++++--------
Aversion.h.in | 6++++++
измењених датотека: 6, додавања: 25(+), брисања: 21(-)

diff --git a/.gitignore b/.gitignore @@ -19,5 +19,5 @@ ufold ufold.1 date version -defs.h +version.h diff --git a/all.do b/all.do @@ -1,2 +1,2 @@ -redo-ifchange ufold ufold.1.gz +redo-ifchange version.h ufold ufold.1.gz diff --git a/defs.h b/defs.h @@ -0,0 +1,8 @@ +/* See the file LICENSE for copyright and license details. */ + +#define MAXBUF 1024 +#define MAXINPUTBUF 4096 +#define MAXPATH 1024 +#define MAX(a,b) ((a) > (b)) ? (a) : (b) +#define MIN(a,b) ((a) < (b)) ? (a) : (b) + diff --git a/defs.h.in b/defs.h.in @@ -1,11 +0,0 @@ -/* See the file LICENSE for copyright and license details. */ - -#define PROGRAMNAME "ufold" -#define VERSION "%VERSION%" -#define DATE "%DATE%" -#define MAXBUF 1024 -#define MAXINPUTBUF 4096 -#define MAXPATH 1024 -#define MAX(a,b) ((a) > (b)) ? (a) : (b) -#define MIN(a,b) ((a) < (b)) ? (a) : (b) - diff --git a/ufold.c b/ufold.c @@ -5,12 +5,13 @@ #include <errno.h> #include <stdarg.h> #include <stdio.h> -#include <string.h> #include <stdint.h> #include <stdlib.h> +#include <string.h> #include "defs.h" #include "utf8.h" +#include "version.h" char filename[MAXPATH]; @@ -235,13 +236,13 @@ fold_line_normal(const u8* line, const int width) int main(int argc, char** argv) { - int argn = 1; - char* carg = NULL; - char** earg = NULL; + int argn = 1; + char* carg = NULL; + char** earg = NULL; char width_buf[MAXBUF]; - int spaces = 0; - int in_width = 0; - long width = 80; + int spaces = 0; + int in_width = 0; + long width = 80; *filename = 0; while (argn < argc) @@ -299,7 +300,7 @@ main(int argc, char** argv) } FILE* input = NULL; - if (*filename == '-' && !*(filename+1)) + if (!*filename || (*filename == '-' && !*(filename+1))) input = stdin; else input = fopen(filename, "rt"); diff --git a/version.h.in b/version.h.in @@ -0,0 +1,6 @@ +/* See the file LICENSE for copyright and license details. */ + +#define PROGRAMNAME "ufold" +#define VERSION "%VERSION%" +#define DATE "%DATE%" +