@@ -111,6 +111,34 @@ static inline gchar *firstword(gchar *input)
111111 return g_strdup (splits [0 ]);
112112}
113113
114+ /**
115+ * Determine if strings are equal, but ignore case sensitivity.
116+ */
117+ static inline bool str_iequal (const gchar * inp , const gchar * cmp )
118+ {
119+ autofree (gchar ) * left = g_ascii_strdown (inp , -1 );
120+ autofree (gchar ) * right = g_ascii_strdown (cmp , -1 );
121+
122+ if (g_str_equal (left , right )) {
123+ return true;
124+ }
125+ return false;
126+ }
127+
128+ /**
129+ * Utility method: Determine if string has the given prefix, case insensitive.
130+ */
131+ static inline bool str_has_iprefix (const gchar * inp , const gchar * cmp )
132+ {
133+ autofree (gchar ) * left = g_ascii_strdown (inp , -1 );
134+ autofree (gchar ) * right = g_ascii_strdown (cmp , -1 );
135+
136+ if (g_str_has_prefix (left , right )) {
137+ return true;
138+ }
139+ return false;
140+ }
141+
114142struct source_package_t * rpm_inspect_spec (const char * filename )
115143{
116144 struct source_package_t * t = NULL ;
@@ -211,22 +239,23 @@ struct source_package_t *rpm_inspect_spec(const char *filename)
211239 value = g_strjoinv (":" , strv + 1 );
212240 value = g_strstrip (value );
213241
214- if (g_str_equal (key , "Name" )) {
242+ if (str_iequal (key , "Name" )) {
215243 name = g_strdup (value );
216- } else if (g_str_equal (key , "Version" )) {
244+ } else if (str_iequal (key , "Version" )) {
217245 version = g_strdup (value );
218- } else if (g_str_equal (key , "Release" )) {
246+ } else if (str_iequal (key , "Release" )) {
219247 release = g_strdup (value );
220- } else if (g_str_has_prefix (key , "Patch" )) {
248+ } else if (str_has_iprefix (key , "Patch" )) {
221249 autofree (gstrv ) * splits = NULL ;
250+ autofree (gchar ) * kkey = g_ascii_strdown (key , -1 );
222251 if (!patches ) {
223252 patches = g_hash_table_new_full (g_str_hash , g_str_equal , g_free , g_free );
224253 if (!patches ) {
225254 g_critical ("Memory allocation failure" );
226255 goto clean ;
227256 }
228257 }
229- splits = g_strsplit (key , "Patch " , 2 );
258+ splits = g_strsplit (kkey , "patch " , 2 );
230259 if (!splits ) {
231260 g_critical ("Memory allocation failure" );
232261 goto clean ;
0 commit comments