Mercurial > hg > octave-nkf
comparison src/utils.cc @ 4264:4e2d2516da22
[project @ 2003-01-03 05:30:34 by jwe]
author | jwe |
---|---|
date | Fri, 03 Jan 2003 05:30:34 +0000 |
parents | df5f2e433a11 |
children | ebc2d8e4968b |
comparison
equal
deleted
inserted
replaced
4263:34b8cd8e6ef5 | 4264:4e2d2516da22 |
---|---|
78 // Return TRUE if S is a valid identifier. | 78 // Return TRUE if S is a valid identifier. |
79 | 79 |
80 bool | 80 bool |
81 valid_identifier (const char *s) | 81 valid_identifier (const char *s) |
82 { | 82 { |
83 if (! s || ! (isalnum (*s) || *s == '_')) | 83 if (! s || ! (isalpha (*s) || *s == '_')) |
84 return false; | 84 return false; |
85 | 85 |
86 while (*++s != '\0') | 86 while (*++s != '\0') |
87 if (! (isalnum (*s) || *s == '_')) | 87 if (! (isalnum (*s) || *s == '_')) |
88 return false; | 88 return false; |
92 | 92 |
93 bool | 93 bool |
94 valid_identifier (const std::string& s) | 94 valid_identifier (const std::string& s) |
95 { | 95 { |
96 return valid_identifier (s.c_str ()); | 96 return valid_identifier (s.c_str ()); |
97 } | |
98 | |
99 DEFCMD (isvarname, args, , | |
100 "@deftypefn {Built-in Function} {} isvarname (@var{name})\n\ | |
101 Return true if @var{name} is a valid variable name\n\ | |
102 @end deftypefn") | |
103 { | |
104 octave_value retval; | |
105 | |
106 int argc = args.length () + 1; | |
107 | |
108 string_vector argv = args.make_argv ("help"); | |
109 | |
110 if (error_state) | |
111 return retval; | |
112 | |
113 if (argc == 2) | |
114 retval = valid_identifier (argv[1]); | |
115 else | |
116 print_usage ("isvarname"); | |
117 | |
118 return retval; | |
97 } | 119 } |
98 | 120 |
99 int | 121 int |
100 almost_match (const std::string& std, const std::string& s, int min_match_len, | 122 almost_match (const std::string& std, const std::string& s, int min_match_len, |
101 int case_sens) | 123 int case_sens) |