mirror of
				https://github.com/troglobit/editline.git
				synced 2025-11-01 01:01:34 +08:00 
			
		
		
		
	Coding style and const fixes to last PR
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
		| @@ -117,37 +117,27 @@ el_status_t do_suspend(void) | ||||
|     return CSstay; | ||||
| } | ||||
|  | ||||
| static int my_rl_check_secret(const char* source) | ||||
| static int my_rl_check_secret(const char *line) | ||||
| { | ||||
|     const char* pattern = (char *)"^unlock\\s"; | ||||
|     const char *pattern = (char *)"^unlock\\s"; | ||||
|     regex_t regex; | ||||
|     int rc = 0; | ||||
|  | ||||
|     int reti; | ||||
|     int rez = 0; | ||||
|     if (!line || regcomp(®ex, pattern, 0)) | ||||
|         return 0; | ||||
|  | ||||
|     if (!pattern || !source) | ||||
|         return rez; | ||||
|     if (!regexec(®ex, line, 0, NULL, 0)) | ||||
|         rc = 1; | ||||
|  | ||||
|     /* Compile regular expression */ | ||||
|     reti = regcomp(®ex, pattern, 0); | ||||
|     if (reti) // If couldn't compile regex | ||||
|         return rez; | ||||
|  | ||||
|     /* Execute regular expression */ | ||||
|     reti = regexec(®ex, source, 0, NULL, 0); | ||||
|     if (!reti) // If regex match | ||||
|         rez = 1; | ||||
|  | ||||
|     /* Free memory allocated to the pattern buffer by regcomp() */ | ||||
|     regfree(®ex); | ||||
|  | ||||
|     return rez; | ||||
|     return rc; | ||||
| } | ||||
|  | ||||
| int main(void) | ||||
| { | ||||
|     char *line; | ||||
|     char	*prompt = "cli> "; | ||||
|     char *prompt = "cli> "; | ||||
|  | ||||
|     /* Setup callbacks */ | ||||
|     rl_set_complete_func(&my_rl_complete); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Joachim Nilsson
					Joachim Nilsson