diff options
Diffstat (limited to '2.3-1/src/c/string')
-rw-r--r-- | 2.3-1/src/c/string/convstr/gconvstrs.c | 19 | ||||
-rw-r--r-- | 2.3-1/src/c/string/includes/convstr.h | 4 | ||||
-rw-r--r-- | 2.3-1/src/c/string/includes/strrchr.h | 26 | ||||
-rw-r--r-- | 2.3-1/src/c/string/includes/strrev.h | 27 | ||||
-rw-r--r-- | 2.3-1/src/c/string/includes/strsubst.h | 27 | ||||
-rw-r--r-- | 2.3-1/src/c/string/interfaces/int_convstr.h | 6 | ||||
-rw-r--r-- | 2.3-1/src/c/string/interfaces/int_strrchr.h | 25 | ||||
-rw-r--r-- | 2.3-1/src/c/string/interfaces/int_strrev.h | 25 | ||||
-rw-r--r-- | 2.3-1/src/c/string/interfaces/int_strsubst.h | 28 | ||||
-rw-r--r-- | 2.3-1/src/c/string/strrchr/gstrrchra.c | 21 | ||||
-rw-r--r-- | 2.3-1/src/c/string/strrev/gstrreva.c | 15 | ||||
-rw-r--r-- | 2.3-1/src/c/string/strsubst/gstrsubsta.c | 57 |
12 files changed, 273 insertions, 7 deletions
diff --git a/2.3-1/src/c/string/convstr/gconvstrs.c b/2.3-1/src/c/string/convstr/gconvstrs.c index d4174965..3db7663e 100644 --- a/2.3-1/src/c/string/convstr/gconvstrs.c +++ b/2.3-1/src/c/string/convstr/gconvstrs.c @@ -1,7 +1,20 @@ #include <string.h> #include "convstr.h" -int gconvstrs(int* in) +void gconvstrs(char* in, int size,char* flag,int size2,char* out) { - return (toupper(in)); -}
\ No newline at end of file + int i=0;//temp=0; + for(i=0;i<size;i++) + { + //temp= in[i]; + if(flag[0]=='l' || flag[0]=='L') + { //temp=temp + 32; + out[i]=tolower(in[i]); + } + else if(flag[0]=='u' || flag[0]=='U') + { + //temp=temp - 32; + out[i]=toupper(in[i]); + } + } +} diff --git a/2.3-1/src/c/string/includes/convstr.h b/2.3-1/src/c/string/includes/convstr.h index 3a8e6e7b..0737c546 100644 --- a/2.3-1/src/c/string/includes/convstr.h +++ b/2.3-1/src/c/string/includes/convstr.h @@ -5,7 +5,7 @@ you should have received as part of this distribution. The terms are also available at http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt - Author: Siddhesh Wani + Author: Shamik Guha Organization: FOSSEE, IIT Bombay Email: toolbox@scilab.in */ @@ -17,7 +17,7 @@ extern "C" { #endif -int gconvstrs(int* in); +void gconvstrs(char* in, int size,char* flag,int size2,char* out); #ifdef __cplusplus } /* extern "C" */ diff --git a/2.3-1/src/c/string/includes/strrchr.h b/2.3-1/src/c/string/includes/strrchr.h new file mode 100644 index 00000000..d06460be --- /dev/null +++ b/2.3-1/src/c/string/includes/strrchr.h @@ -0,0 +1,26 @@ + /* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Shamik Guha + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __STRRCHR_H__ +#define __STRRCHR_H__ + + + #ifdef __cplusplus + extern "C" { + #endif + +void gstrrchr(char* str,int size,char* key,int size2,char* out); + + #ifdef __cplusplus + } /* extern "C" */ + #endif + +#endif /*__STRRCHR_H__*/ diff --git a/2.3-1/src/c/string/includes/strrev.h b/2.3-1/src/c/string/includes/strrev.h new file mode 100644 index 00000000..c7e79570 --- /dev/null +++ b/2.3-1/src/c/string/includes/strrev.h @@ -0,0 +1,27 @@ + /* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Shamik Guha + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __STRREV_H__ +#define __STRREV_H__ + + + #ifdef __cplusplus + extern "C" { + #endif + +void gstrreva(char* str,int size,char* out); +//void gstrrevs(char* in, int size,char* search, int size2, char* rep, int size3, ,char* out); + + #ifdef __cplusplus + } /* extern "C" */ + #endif + +#endif /*__STRREV_H__*/ diff --git a/2.3-1/src/c/string/includes/strsubst.h b/2.3-1/src/c/string/includes/strsubst.h new file mode 100644 index 00000000..e9eba429 --- /dev/null +++ b/2.3-1/src/c/string/includes/strsubst.h @@ -0,0 +1,27 @@ + /* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Shamik Guha + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __STRSUBST_H__ +#define __STRSUBST_H__ + + + #ifdef __cplusplus + extern "C" { + #endif + +void gstrsubsta(char* str, int size, char* search, int size2, char* rep, int size3, char* flagmain,int size4, char* out); +//void gstrsubsta(char* str, int size, char* search, int size2, char* rep, int size3, char* out,int size5); + + #ifdef __cplusplus + } /* extern "C" */ + #endif + +#endif /*__STRSUBST_H__*/ diff --git a/2.3-1/src/c/string/interfaces/int_convstr.h b/2.3-1/src/c/string/interfaces/int_convstr.h index f565b858..fee3d373 100644 --- a/2.3-1/src/c/string/interfaces/int_convstr.h +++ b/2.3-1/src/c/string/interfaces/int_convstr.h @@ -5,7 +5,7 @@ you should have received as part of this distribution. The terms are also available at http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt - Author: Siddhesh Wani + Author: Shamik Guha Organization: FOSSEE, IIT Bombay Email: toolbox@scilab.in */ @@ -16,7 +16,9 @@ extern "C" { #endif -#define g0constrg0(in, size) gconstrs(in) +#define g2g2convstrg2(in,size,flag,size2,out) gconvstrs(in,size[0]*size[1],flag,size2[1],out) +//#define g2g2convstrg0(in,size,type,typesize,out) (type=='u': \ + gconvstrs(in,size[0]*size[1],0,out)?gconvstrs(in,size[0]*size[1],1,out)) #ifdef __cplusplus } /* extern "C" */ diff --git a/2.3-1/src/c/string/interfaces/int_strrchr.h b/2.3-1/src/c/string/interfaces/int_strrchr.h new file mode 100644 index 00000000..7ec94ebe --- /dev/null +++ b/2.3-1/src/c/string/interfaces/int_strrchr.h @@ -0,0 +1,25 @@ + /* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Shamik Guha + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_STRRCHR_H__ +#define __INT_STRRCHR_H__ + + #ifdef __cplusplus + extern "C" { + #endif + +#define g2g2strrchrg2(str,size,key,size2,out) gstrrchra(str,size[1],key,size2[1],out) + + #ifdef __cplusplus + } /* extern "C" */ + #endif + +#endif /*__INT_STRRCHR_H__*/ diff --git a/2.3-1/src/c/string/interfaces/int_strrev.h b/2.3-1/src/c/string/interfaces/int_strrev.h new file mode 100644 index 00000000..8429f6a1 --- /dev/null +++ b/2.3-1/src/c/string/interfaces/int_strrev.h @@ -0,0 +1,25 @@ + /* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Shamik Guha + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_STRREV_H__ +#define __INT_STRREV_H__ + + #ifdef __cplusplus + extern "C" { + #endif + +#define g2strrevg2(str,size,out) gstrreva(str,size[1],out) + + #ifdef __cplusplus + } /* extern "C" */ + #endif + +#endif /*__INT_STRREV_H__*/ diff --git a/2.3-1/src/c/string/interfaces/int_strsubst.h b/2.3-1/src/c/string/interfaces/int_strsubst.h new file mode 100644 index 00000000..c8dd67a1 --- /dev/null +++ b/2.3-1/src/c/string/interfaces/int_strsubst.h @@ -0,0 +1,28 @@ + /* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Shamik Guha + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_STRSUBST_H__ +#define __INT_STRSUBST_H__ + + #ifdef __cplusplus + extern "C" { + #endif + +#define g2g2g2g2strsubstg2(str,size,search,size2,rep,size3,flagmain,size4,out) gstrsubsta(str,size[1],search,size2[1],rep,size3[1],flagmain,size4[1],out) +#define g2g2g2strsubstg2(in,size,search,size2,rep,size3,out) gstrsubsta(in,size[1],search,size2[1],rep,size3[1],'s',size3[1],out) + + + + #ifdef __cplusplus + } /* extern "C" */ + #endif + +#endif /*__INT_STRSUBST_H__*/ diff --git a/2.3-1/src/c/string/strrchr/gstrrchra.c b/2.3-1/src/c/string/strrchr/gstrrchra.c new file mode 100644 index 00000000..460c1f2f --- /dev/null +++ b/2.3-1/src/c/string/strrchr/gstrrchra.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <string.h> +#include "strrchr.h" + +void gstrrchra(char* str,int size,char* key,int size2,char* out) +{ + int i,j, k=0, pos2; + + for (i = 0;i<size;i++) + { + if (key[0] == str[i]) + { + pos2 = i; + } + } + for(j=pos2;j<i;j++) + { + out[k]=str[j]; + k++; + } +} diff --git a/2.3-1/src/c/string/strrev/gstrreva.c b/2.3-1/src/c/string/strrev/gstrreva.c new file mode 100644 index 00000000..8ceb16ab --- /dev/null +++ b/2.3-1/src/c/string/strrev/gstrreva.c @@ -0,0 +1,15 @@ +#include<stdio.h> +#include "strrev.h" + +void gstrreva(char* str,int size,char* out) +{ + int i=-1,j=0; + + while(str[++i]!='\0'); + + while(i>=0) + out[j++] = str[--i]; + + out[j]='\0'; + +} diff --git a/2.3-1/src/c/string/strsubst/gstrsubsta.c b/2.3-1/src/c/string/strsubst/gstrsubsta.c new file mode 100644 index 00000000..69ebf3c5 --- /dev/null +++ b/2.3-1/src/c/string/strsubst/gstrsubsta.c @@ -0,0 +1,57 @@ +#include <stdio.h> +#include <string.h> +#include "strsubst.h" + +void gstrsubsta(char* str,int size, char* search, int size2, char* rep, int size3, char* flagmain, int size4, char* out) +{ + int i = 0, j = 0, flag = 0, start = 0; + + //if(flagmain[0]!='r') + //{ + while (str[i] != '\0') + { + if (str[i] == search[j]) + { + if (!flag) + start = i; + j++; + if (search[j] == '\0') + break; + flag = 1; + } + else + { + flag = start = j = 0; + } + i++; + } + + if (search[j] == '\0' && flag) + { + for (i = 0; i < start; i++) + out[i] = str[i]; + /* rep string with another string */ + for (j = 0; j < strlen(rep); j++) + { + out[i] = rep[j]; + i++; + } + + /* copy remaining portion of the input string "str" */ + for (j = start + strlen(search); j < strlen(str); j++) + { + out[i] = str[j]; + i++; + } + + /* print the out string */ + out[i] = '\0'; + //printf("Output: %s\n", out); + } + else + { + printf("%s is not a searching of %s\n", search, str); + } + // } + +} |