src/scripts/swigwin/Source/Modules/cffi.cxx
String *CFFI::strip_parens(String *string) {
  char *s = Char(string), *p;
  int len = Len(string);
  String *res;

  if (len == 0 || s[0] != '(' || s[len - 1] != ')') {
    return NewString(string);
  }

  p = (char *) malloc(len - 2 + 1);
  if (!p) {
    Printf(stderr, "Malloc failed\n");
    SWIG_exit(EXIT_FAILURE);
  }

  strncpy(p, s + 1, len - 1);
  p[len - 2] = 0;   /* null terminate */

  res = NewString(p);
  free(p);

  return res;
}
/* utilities */
/* returns new string w/ parens stripped */
utilities
returns new string w/ parens stripped
utilities returns new string w / parens stripped
String *CFFI::strip_parens(String *string) {
  char *s = Char(string), *p;
  int len = Len(string);
  String *res;
  if (len == 0 || s[0] != '(' || s[len - 1] != ')') {
    return NewString(string);
  }
  p = (char *) malloc(len - 2 + 1);
  if (!p) {
    Printf(stderr, "Malloc failed\n");
    SWIG_exit(EXIT_FAILURE);
  }
  strncpy(p, s + 1, len - 1);
  p[len - 2] = 0;   
  res = NewString(p);
  free(p);
  return res;
}
String * CFFI :: strip_parens ( String * string ) { char * s = Char ( string ) , * p ; int len = Len ( string ) ; String * res ; if ( len == 0 || s [ 0 ] != ' ' || s [ len - 1 ] != ' ' ) { return NewString ( string ) ; } p = ( char * ) malloc ( len - 2 + 1 ) ; if ( ! p ) { Printf ( stderr , " \n " ) ; SWIG_exit ( EXIT_FAILURE ) ; } strncpy ( p , s + 1 , len - 1 ) ; p [ len - 2 ] = 0 ; res = NewString ( p ) ; free ( p ) ; return res ; }
utilities
returns new string w/ parens stripped
utilities returns new string w / parens stripped
/* null terminate */