spicylord / clutils (public) (License: GPLv3) (since 2019-07-04) (hash sha1)
An assortment of new and rewritten preexisting tools written by me.
List of commits:
Subject Hash Author Date (UTC)
reverted sc because I cannot into memory management. ins is suffering from memory as well so use at your own risk. 1f24dcf261e3d779782a5e5ba2bd0c26da0fd928 spicylord 2019-08-17 19:10:51
im an idiot c6aa7a7fa124fb08422fb24de68ecb70ba066195 spicylord 2019-08-16 04:30:23
bug fixes 5ec9e0063dee0e8cb9b7c88a06535a1c13faa2af spicylord 2019-08-16 04:20:21
added free for previously unfreed malloc buffer fbuf ec2c9bbcb387a718d36bd861083ac2c40134c152 spicylord 2019-08-16 02:01:00
put all of the programs under the GPLv3 or later, also updated sc.c 77dbf20cedc357042ffc03e5da9a51690337a977 spicylord 2019-08-16 01:08:49
added ins to INSTALL script 6d58cd823d49a8ad4a32a57173d5d690ddb677c6 spicylord 2019-08-15 21:23:41
added ins, a program that takes standard input and inserts that into the beginning of a file c51d12a96e47c407a2e82980401556194b2c090e matt 2019-08-15 21:17:47
added exho, a program that runs a command and outputs that command to stdout 4c7b8d4998e747541c420256494cee40ff19fc12 spicylord 2019-07-12 02:29:35
allow for easy use of different c compilers in INSTALL a1bb4ec6cdbd070edb7955022f93ff33ca7255da spicylord 2019-07-11 16:16:46
made COPYING less cringe-inducing 8d1e9ca0093f143c25b919552b544db92c9f865d spicylord 2019-07-10 01:32:22
modified usage output and allowed for #,p 504ca7b3d8db60cb6d1f36a3fd48043ff62f78c0 spicylord 2019-07-06 15:49:16
spelling error in README 351dbee78173eef7ae94f9142c6a97452db0d208 spicylord 2019-07-04 20:30:33
added examples and instructions for clp, spng, and sc in the README 313a86755e40d909861bc95a11b75bbb109012c9 spicylord 2019-07-04 19:25:33
made regex slightly neater ac8eda8f7290e5f138edac12f789b1215de90719 spicylord 2019-07-04 18:31:55
fixed outputting garbled text into clipboard file a100287acf1993ae13130e036d7104bd2afe4585 spicylord 2019-07-04 18:30:34
fixed install script to compile clp.c instead of clb.c 54a54b5da1a122e69ed62bc0f030f11044a62fb9 spicylord 2019-07-04 13:47:33
added email a04151394c9a4b3afe23e8ebd11939fe7892737d spicylord 2019-07-04 02:58:00
initial commit 484a7ed27b1835a962cec85cc6f55a20d4a95b46 spicylord 2019-07-04 02:50:23
Commit 1f24dcf261e3d779782a5e5ba2bd0c26da0fd928 - reverted sc because I cannot into memory management. ins is suffering from memory as well so use at your own risk.
Author: spicylord
Author date (UTC): 2019-08-17 19:10
Committer name: spicylord
Committer date (UTC): 2019-08-17 19:10
Parent(s): c6aa7a7fa124fb08422fb24de68ecb70ba066195
Signing key:
Tree: 4100b2ce5666916a9a777b5b9c4f383117fed865
File Lines added Lines deleted
clp.c 1 1
echo.c 61 1
exho.c 1 1
ins.c 4 1
nl.l 1 1
sc.c 24 32
spng.c 1 1
tee.c 1 1
wc.c 1 1
yes.c 0 29
File clp.c changed (mode: 100644) (index 65ea387..10d3ad5)
1 1 /* /*
2 Copyright 2019 Matthew Graham <sl@airmail.cc>
2 Copyright (c) 2019 Matthew Graham
3 3
4 4 This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
5 5 it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
File echo.c changed (mode: 100644) (index 0f2b94b..3f3c327)
1 1 /* /*
2 Copyright 2019 Matthew Graham <sl@airmail.cc>
2 Copyright (c) 2019 Matthew Graham
3 3
4 4 This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
5 5 it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
 
... ... int main(int argc, char *argv[])
24 24 printf("%s%c", argv[i], i==argc? '\n':' '); printf("%s%c", argv[i], i==argc? '\n':' ');
25 25 return 0; return 0;
26 26 } }
27 )
28 if (memcmp(tester, delim, sizeof(delim)-1)==0)
29 end++;
30 rewind(filep);
31
32 if (ocountflag) {
33 printf("%ld\n", end);
34 goto ending; /* stops program after outputting count */
35 }
36
37 if (end==0) {
38 fputs("nothing to act on\n", stderr);
39 fclose(filep);
40 exit(1);
41 }
42 if (to>end) {
43 fputs("clip: end point too big\n", stderr);
44 fclose(filep);
45 exit(1);
46 }
47 if (!from && !to && commaflag) { from=1; to=end; }
48 if (!from && !to && !commaflag) { from = end; to = end; }
49 if (from && !to && commaflag) to = end;
50 if (delflag) {
51 int delimflag=0;
52 if ((tdelfilep=fopen(".clipboard~~~", "w+"))==NULL) {
53 fputs("clip: cannot create temporary file\n", stderr);
54 fclose(filep);
55 exit(1);
56 }
57 while (counter <= end && fgets(tester, sizeof(tester), filep)) {
58 if (memcmp(tester, delim, sizeof(delim)-1)==0) {
59 counter++;
60 delimflag=1;
61 continue;
62 }
63 if (counter < from || counter > to) {
64 fprintf(tdelfilep, "%s%s", delimflag?delim:"", tester);
65 delimflag=0;
66 }
67 }
68 rename(".clipboard~~~", filename);
69 goto ending;
70 }
71
72 if (outflag) {
73 while (counter <= end && fgets(tester, sizeof(tester), filep)) {
74 if (memcmp(tester, delim, sizeof(delim)-1)==0) {
75 counter++;
76 continue;
77 }
78 if (counter >= from && counter <= to) {
79 fputs(tester, stdout);
80 }
81 }
82 }
83 ending:
84 fclose(filep);
85 exit(0);
86 }
File exho.c changed (mode: 100644) (index 5f4f192..35eac8c)
1 1 /* /*
2 Copyright 2019 Matthew Graham <sl@airmail.cc>
2 Copyright (c) 2019 Matthew Graham
3 3
4 4 This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
5 5 it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
File ins.c changed (mode: 100644) (index 21b792b..29646d8)
1 1 /* /*
2 Copyright 2019 Matthew Graham <sl@airmail.cc>
2 Copyright (c) 2019 Matthew Graham
3 3
4 4 This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
5 5 it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
 
... ... int main(int argc, char *argv[])
24 24 FILE *fp, *tfp; FILE *fp, *tfp;
25 25 char *fbuf; char *fbuf;
26 26 char *buf; char *buf;
27 char *null=0;
27 28 long fsize, tsize; long fsize, tsize;
28 29 char instext[100000]; char instext[100000];
29 30 fread(instext, sizeof(instext), 1, stdin); fread(instext, sizeof(instext), 1, stdin);
 
... ... int main(int argc, char *argv[])
45 46 strcat(buf, fbuf); strcat(buf, fbuf);
46 47 fputs(buf, tfp); fputs(buf, tfp);
47 48 rename(".instemp~~~", argv[i]); rename(".instemp~~~", argv[i]);
49 strcpy(buf, null);
48 50 free(buf); free(buf);
51 strcpy(fbuf, null);
49 52 free(fbuf); free(fbuf);
50 53 fclose(fp); fclose(fp);
51 54 fclose(tfp); fclose(tfp);
File nl.l changed (mode: 100644) (index 4c5b7c9..89b230a)
1 1 /* /*
2 Copyright 2019 Matthew Graham <sl@airmail.cc>
2 Copyright (c) 2019 Matthew Graham
3 3
4 4 This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
5 5 it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
File sc.c changed (mode: 100644) (index 7dbeee4..d59401d)
1 1 /* /*
2 Copyright 2019 Matthew Graham <sl@airmail.cc>
2 Copyright (c) 2019 Matthew Graham
3 3
4 4 This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
5 5 it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
 
... ... GNU General Public License for more details.
14 14 You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
15 15 along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
16 16 */ */
17
18 17 #include <stdio.h> #include <stdio.h>
19 #include <stdlib.h>
20 18
21 19 int main(int argc, char *argv[]) int main(int argc, char *argv[])
22 20 { {
23 char *buf;
21 int character;
24 22 unsigned int ccase = 0; unsigned int ccase = 0;
25 long size;
26 int i = 1;
27 FILE *fp = stdin;
23 int iter = 1;
24 FILE *filep = stdin;
28 25 if (argv[1] && argv[1][0]=='-' && argv[1][1]) { if (argv[1] && argv[1][0]=='-' && argv[1][1]) {
29 26 switch (argv[1][1]) { switch (argv[1][1]) {
30 27 case 'l': ccase = 'l'; break; case 'l': ccase = 'l'; break;
 
... ... int main(int argc, char *argv[])
40 37 argv++; argv++;
41 38
42 39 do { do {
43 if (argc > 1 && (fp=fopen(argv[i], "r"))==NULL) {
44 fprintf(stderr, "sc: unable to open %s\n", argv[i]);
40 if (argc > 1 && (filep=fopen(argv[iter], "r"))==NULL) {
41 fprintf(stderr, "sc: unable to open %s\n", argv[iter]);
45 42 continue; continue;
46 43 } }
47 fseek(fp, 0L, SEEK_END);
48 size = ftell(fp);
49 rewind(fp);
50 buf = malloc(size+1);
51 fread(buf, size, 1, fp);
44
52 45 switch (ccase) { switch (ccase) {
53 46 case 'l': case 'l':
54 for (int a=0; buf[a]; a++) {
55 if (buf[a] >= 'A' && buf[a] <= 'Z')
56 buf[a] += 32;
57 putchar(buf[a]);
47 while ((character = fgetc(filep))!=EOF) {
48 if (character >= 'A' && character <= 'A')
49 character += 32;
50 putchar(character);
58 51 } }
59 52 break; break;
60 53
61 54 case 'u': case 'u':
62 for (int b=0; buf[b]; b++) {
63 if (buf[b] >= 'a' && buf[b] <= 'z')
64 buf[b] -= 32;
65 putchar(buf[b]);
55 while ((character = fgetc(filep))!=EOF) {
56 if (character >= 'a' && character <= 'z')
57 character -= 32;
58 putchar(character);
66 59 } }
67 60 break; break;
68 61
69 62 case 's': case 's':
70 for (int c=0; buf[c]; c++) {
71 if (buf[c] >= 'a' && buf[c] <= 'z') {
72 buf[c] -= 32;
73 putchar(buf[c]);
63 while ((character = fgetc(filep))!=EOF) {
64 if (character >= 'a' && character <= 'z') {
65 character -= 32;
66 putchar(character);
74 67 continue; continue;
75 68 } }
76 else if (buf[c] >= 'A' && buf[c] <= 'Z') {
77 buf[c] += 32;
78 putchar(buf[c]);
69 else if (character >= 'A' && character <= 'Z') {
70 character += 32;
71 putchar(character);
79 72 continue; continue;
80 73 } }
81 putchar(buf[c]);
74 putchar(character);
82 75 } }
83 76 break; break;
84 77 } }
85 free(buf);
86 } while (++i<argc);
78 } while (++iter<argc);
87 79 return 0; return 0;
88 80 } }
File spng.c changed (mode: 100644) (index 6e2a3e1..b55bcc8)
1 1 /* /*
2 Copyright 2019 Matthew Graham <sl@airmail.cc>
2 Copyright (c) 2019 Matthew Graham
3 3
4 4 This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
5 5 it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
File tee.c changed (mode: 100644) (index 4f47af1..1433a01)
1 1 /* /*
2 Copyright 2019 Matthew Graham <sl@airmail.cc>
2 Copyright (c) 2019 Matthew Graham
3 3
4 4 This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
5 5 it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
File wc.c changed (mode: 100644) (index 1176130..f3b9072)
1 1 /* /*
2 Copyright 2019 Matthew Graham <sl@airmail.cc>
2 Copyright (c) 2019 Matthew Graham
3 3
4 4 This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
5 5 it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
File yes.c changed (mode: 100644) (index b2f6b39..e69de29)
1 /*
2 Copyright 2019 Matthew Graham <sl@airmail.cc>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18 #include <stdio.h>
19
20 int main(int argc, char *argv[])
21 {
22 if (argc==1)
23 for(;;)
24 puts("y");
25 else
26 for (;;)
27 puts(argv[1]);
28 return 1;
29 }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/spicylord/clutils

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/spicylord/clutils

Clone this repository using git:
git clone git://git.rocketgit.com/user/spicylord/clutils

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main