53 lines
1.8 KiB
Diff
53 lines
1.8 KiB
Diff
#Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
|
|
#
|
|
#This program is free software; you can redistribute it and/or modify
|
|
#it under the terms of GPLv2+ and LGPLv2+
|
|
#
|
|
#This program is distributed in the hope that it will be useful,
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See GPLv2+ and LGPLv2+ for more details.
|
|
|
|
diff -uNrp a/contrib/command-not-found/pk-command-not-found.c b/contrib/command-not-found/pk-command-not-found.c
|
|
--- a/contrib/command-not-found/pk-command-not-found.c 2018-09-25 16:37:29.000000000 +0800
|
|
+++ b/contrib/command-not-found/pk-command-not-found.c 2019-08-26 10:14:11.184000000 +0800
|
|
@@ -143,6 +143,31 @@ pk_cnf_find_alternatives_replace (const
|
|
|
|
/**
|
|
*
|
|
+ * Add last char, so gre -> grep
|
|
+ **/
|
|
+static void
|
|
+pk_cnf_find_alternatives_add (const gchar *cmd, guint len, GPtrArray *array)
|
|
+{
|
|
+ guint i;
|
|
+ gchar *possible;
|
|
+ gchar *alt="abcdefghijklmnopqrstuvwxyz";
|
|
+ for(i = 0;i < 26; i++)
|
|
+ {
|
|
+ gchar *temp = malloc((len+2)*sizeof(gchar));
|
|
+ if(NULL != temp)
|
|
+ {
|
|
+ memset(temp,0,(len+2)*sizeof(gchar));
|
|
+ strncpy(temp,cmd,len);
|
|
+ temp[len]=alt[i];
|
|
+ temp[len+1]='\0';
|
|
+ possible = temp;
|
|
+ g_ptr_array_add (array, possible);
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
+/**
|
|
+ *
|
|
* Truncate first and last char, so lshall -> lshal
|
|
**/
|
|
static void
|
|
@@ -349,6 +374,7 @@ pk_cnf_find_alternatives (const gchar *c
|
|
unique = g_ptr_array_new ();
|
|
pk_cnf_find_alternatives_swizzle (cmd, len, possible);
|
|
pk_cnf_find_alternatives_replace (cmd, len, possible);
|
|
+ pk_cnf_find_alternatives_add (cmd, len, possible);
|
|
if (len > 3)
|
|
pk_cnf_find_alternatives_truncate (cmd, len, possible);
|
|
pk_cnf_find_alternatives_remove_double (cmd, len, possible);
|