-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: fmrl-client action: blob revision: path_from: clump.c revision_from: refs/heads/trunk: path_to: revision_to:
/ clump.c
refs/heads/trunk:/clump.c #include <stdio.h> #include <stdlib.h> #include <string.h> //clumps together consecutive rows containing the same first column //to have column 2- printed after a single column 1 value. //just try it out. //printf "a a\na b\na c\nb a\nb b\nc a\nc b\n" | clump //still working on the name. int main(int argc,char *argv[]) { char line[256]; char *id; char sep=' '; char *value; char *oldid=malloc(1); *oldid=0; if(argc > 1) sep=argv[1][0]; while(fgets(line,sizeof(line),stdin)) { id=line; if(strchr(line,'\n')) *strchr(line,'\n')=0; if(strchr(id,sep)) { value=strchr(id,sep); *value=0; value++; } if(strcmp(id,oldid)) { if(*oldid != 0) { printf("\n"); } printf("%s:",id); free(oldid); oldid=strdup(id); } printf(" %s",value); } printf("\n"); return 0; }
-- Response ended
-- Page fetched on Sun Jun 2 15:29:26 2024