//pkginst/rtrim.c |
---|
File deleted |
//pkginst/rtrim.h |
---|
File deleted |
//pkginst/Makefile |
---|
9,7 → 9,7 |
all: pkginst.exe |
pkginst.exe: kitten.obj main.obj crc32.obj fileexst.obj helpers.obj inf.obj kprintf.obj libunzip.obj loadconf.obj lsm.obj parsecmd.obj pkginst.obj pkgrem.obj rtrim.obj showinst.obj |
pkginst.exe: kitten.obj main.obj crc32.obj fileexst.obj helpers.obj inf.obj kprintf.obj libunzip.obj loadconf.obj lsm.obj parsecmd.obj pkginst.obj pkgrem.obj trim.obj showinst.obj |
wcl $(LDFLAGS) $(LIBS) *.obj |
kitten.obj: kitten\kitten.c |
51,8 → 51,8 |
pkgrem.obj: pkgrem.c |
wcc $(CFLAGS) pkgrem.c |
rtrim.obj: rtrim.c |
wcc $(CFLAGS) rtrim.c |
trim.obj: trim.c |
wcc $(CFLAGS) trim.c |
showinst.obj: showinst.c |
wcc $(CFLAGS) showinst.c |
//pkginst/helpers.c |
---|
13,7 → 13,7 |
#include <stdlib.h> /* atoi() */ |
#include <sys/stat.h> /* mkdir() */ |
#include "rtrim.h" |
#include "trim.h" |
#include "helpers.h" |
//pkginst/trim.c |
---|
0,0 → 1,35 |
/* |
* trims any space, tab, cr or lf |
* Copyright (C) 2012-2021 Mateusz Viste |
*/ |
#include "trim.h" |
void trim(char *str) { |
int x, y, firstchar = -1, lastchar = -1; |
/* find out first and last non-whitespace char */ |
for (x = 0; str[x] != 0; x++) { |
switch (str[x]) { |
case ' ': |
case '\t': |
case '\n': |
case '\r': |
break; |
default: |
if (firstchar < 0) firstchar = x; |
lastchar = x; |
break; |
} |
} |
/* right trim */ |
str[lastchar + 1] = 0; |
/* left trim (shift to the left ) */ |
if (firstchar > 0) { |
y = 0; |
for (x = firstchar; str[x] != 0; x++) str[y++] = str[x]; |
str[y] = 0; |
} |
} |
//pkginst/trim.h |
---|
0,0 → 1,11 |
/* |
* trims any space, tab, cr or lf |
* Copyright (C) 2012-2021 Mateusz Viste |
*/ |
#ifndef trim_sentinel |
#define trim_sentinel |
void trim(char *str); |
#endif |