This commit is contained in:
Your Name 2024-01-06 15:36:11 +03:00
parent dfc04ea0e2
commit 2b3d629800
3 changed files with 10 additions and 14 deletions

1
TODO
View File

@ -4,7 +4,6 @@ With "micro-" prefix
tail
expr
uniq
seq
od
split
date

View File

@ -4,15 +4,7 @@
#include <string.h>
#include <libgen.h>
void remove_suffix(char *base, const char *suffix) {
char *ptr = base + strlen(base) - strlen(suffix);
if (!strcmp(ptr, suffix))
*ptr = '\0';
}
int main(int argc, char **argv) {
char *suffix = NULL;
char *base = NULL;
int opt;
while ((opt = getopt(argc, argv, "")) != -1) {
@ -23,12 +15,17 @@ int main(int argc, char **argv) {
argv += optind;
argc -= optind;
char *suffix = NULL;
if (argc == 2)
suffix = argv[1];
base = basename(argv[0]);
if (suffix)
remove_suffix(base, suffix);
char *base = basename(argv[0]);
if (suffix) {
char *ptr = base + strlen(base) - strlen(suffix);
if (!strcmp(ptr, suffix))
*ptr = '\0';
}
puts(base);
return 0;

View File

@ -47,12 +47,12 @@ int main(int argc, char **argv) {
if (start <= last && n >= 0) {
for (double i = start; i <= last; i += n)
printf("%.f\n", i);
printf("%g\n", i);
}
else if (n <= 0)
for (double i = start; i >= last; i += n)
printf("%.f\n", i);
printf("%g\n", i);
return 0;
}