Skip to content

Instantly share code, notes, and snippets.

@kulp
Created May 28, 2009 15:07
Show Gist options
  • Save kulp/119371 to your computer and use it in GitHub Desktop.
Save kulp/119371 to your computer and use it in GitHub Desktop.
Make cyclo show only C function names instead of concatenating pieces of the signature. Won't be nice to C++.
--- cyclo-2.0/lib.C 1994-07-03 13:12:34.000000000 -0500
+++ cyclo-2.0-kulp/lib.C 2009-05-28 10:08:23.000000000 -0500
@@ -23,35 +23,16 @@
extern "C" // called from 'C' scan.c
{
-char *strndup(char *str, int n)
-{
- char *t, *t2;
- t2=t=(char *)malloc(n+1*sizeof(char));
- if(!t) { cerr << "Out of memory in " << __FILE__ << " line " << __LINE__ << "\n"; exit(1);}
-
- while(n && str)
- {
- *t2=*str;
- n--;
- str++;
- t2++;
- }
- *t2=0;
- return t;
-}
-
char *getfunc(char *str, int n)
{
char *t=strndup(str, n-1); /* leave off terminating parenthesis */
- char *t2=t;
+ char *t2=t+n-2;
- while(*t)
- {
- if(*t==' ' || *t=='\t' || *t=='\n')
- strcpy(t, t+1);
- t++;
- }
- return t2;
+ while ( *t2==' ' || *t2=='\t' || *t2=='\n') *t2 = 0, t2--;
+ while (t2 > t && *t2!=' ' && *t2!='\t' && *t2!='\n') t2--;
+ if (t2 > t) strcpy(t, t2 + 1);
+
+ return t;
}
char *getarg(char *str, int n, char *keyword)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment