Moved legacy code into archive, ready for a new rapid(?) prototype.
I may regret doing this!
This commit is contained in:
parent
09051a3e63
commit
914c35ead0
114 changed files with 165 additions and 1 deletions
33
archive/c/utils.c
Normal file
33
archive/c/utils.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* utils.c
|
||||
*
|
||||
* little generally useful functions which aren't in any way special to PSSE.
|
||||
*
|
||||
* (c) 2019 Simon Brooke <simon@journeyman.cc>
|
||||
* Licensed under GPL version 2.0, or, at your option, any later version.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int index_of( char c, const char *s ) {
|
||||
int i;
|
||||
|
||||
for ( i = 0; s[i] != c && s[i] != 0; i++ );
|
||||
|
||||
return s[i] == c ? i : -1;
|
||||
}
|
||||
|
||||
char *trim( char *s ) {
|
||||
int i;
|
||||
|
||||
for ( i = strlen( s ); ( isblank( s[i] ) || iscntrl( s[i] ) ) && i >= 0;
|
||||
i-- ) {
|
||||
s[i] = '\0';
|
||||
}
|
||||
for ( i = 0; s[i] != '\0' && ( isblank( s[i] ) || iscntrl( s[i] ) ); i++ );
|
||||
|
||||
return ( char * ) &s[i];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue