@@ -113,9 +113,9 @@ struct path_linked_list* path_linked_list_new(void)
113113 *
114114 * Free the entire linked list
115115 **/
116- void path_linked_list_free (struct path_linked_list * in_path_linked_list )
116+ void path_linked_list_free (struct path_linked_list * in_path_llist )
117117{
118- struct path_linked_list * node_tmp = (struct path_linked_list * )in_path_linked_list ;
118+ struct path_linked_list * node_tmp = (struct path_linked_list * )in_path_llist ;
119119 while (node_tmp )
120120 {
121121 struct path_linked_list * hold = NULL ;
@@ -135,35 +135,34 @@ void path_linked_list_free(struct path_linked_list *in_path_linked_list)
135135 * If the first node's path if it's not yet set the path
136136 * on this node instead
137137**/
138- void path_linked_list_add_path (struct path_linked_list * in_path_linked_list ,
138+ void path_linked_list_add_path (struct path_linked_list * in_path_llist ,
139139 char * path )
140140{
141141 /* If the first item does not have a path this is
142142 a list which has just been created, so we just fill
143143 the path for the first item
144144 */
145- if (!in_path_linked_list -> path )
146- in_path_linked_list -> path = strdup (path );
145+ if (!in_path_llist -> path )
146+ in_path_llist -> path = strdup (path );
147147 else
148148 {
149149 struct path_linked_list * node = (struct path_linked_list * ) malloc (sizeof (* node ));
150150
151151 if (node )
152152 {
153- struct path_linked_list * head = in_path_linked_list ;
153+ struct path_linked_list * head = in_path_llist ;
154154
155- node -> next = NULL ;
156- node -> path = strdup (path );
155+ node -> next = NULL ;
156+ node -> path = strdup (path );
157157
158158 if (head )
159159 {
160160 while (head -> next )
161161 head = head -> next ;
162-
163162 head -> next = node ;
164163 }
165164 else
166- in_path_linked_list = node ;
165+ in_path_llist = node ;
167166 }
168167 }
169168}
@@ -330,14 +329,12 @@ bool path_is_compressed_file(const char* path)
330329size_t fill_pathname (char * s , const char * in_path ,
331330 const char * replace , size_t len )
332331{
333- size_t _len ;
334- char tmp_path [PATH_MAX_LENGTH ];
335332 char * tok = NULL ;
336- strlcpy (tmp_path , in_path , sizeof ( tmp_path ) );
337- if ((tok = (char * )strrchr (path_basename (tmp_path ), '.' )))
338- * tok = '\0' ;
339-
340- _len = strlcpy ( s , tmp_path , len );
333+ size_t _len = strlcpy (s , in_path , len );
334+ if ((tok = (char * )strrchr (path_basename (s ), '.' )))
335+ {
336+ * tok = '\0' ; _len = tok - s ;
337+ }
341338 _len += strlcpy (s + _len , replace , len - _len );
342339 return _len ;
343340}
@@ -377,7 +374,7 @@ size_t fill_pathname_slash(char *s, size_t len)
377374 char * last_slash = (!slash || (backslash > slash )) ? (char * )backslash : (char * )slash ;
378375 if (!last_slash )
379376 return strlcat (s , PATH_DEFAULT_SLASH (), len );
380- len = strlen (s );
377+ len = strlen (s );
381378 /* Try to preserve slash type. */
382379 if (last_slash != (s + len - 1 ))
383380 {
@@ -407,10 +404,9 @@ size_t fill_pathname_slash(char *s, size_t len)
407404size_t fill_pathname_dir (char * s , const char * in_basename ,
408405 const char * replace , size_t len )
409406{
410- size_t _len = fill_pathname_slash (s , len );
411- const char * base = path_basename (in_basename );
412- _len += strlcpy (s + _len , base , len - _len );
413- _len += strlcpy (s + _len , replace , len - _len );
407+ size_t _len = fill_pathname_slash (s , len );
408+ _len += strlcpy (s + _len , path_basename (in_basename ), len - _len );
409+ _len += strlcpy (s + _len , replace , len - _len );
414410 return _len ;
415411}
416412
@@ -518,10 +514,10 @@ void fill_pathname_parent_dir(char *s,
518514 const char * in_dir , size_t len )
519515{
520516 size_t _len = 0 ;
521- if (s != in_dir )
522- _len = strlcpy (s , in_dir , len );
523- else
517+ if (s == in_dir )
524518 _len = strlen (s );
519+ else
520+ _len = strlcpy (s , in_dir , len );
525521 path_parent_dir (s , _len );
526522}
527523
@@ -1051,13 +1047,13 @@ size_t fill_pathname_join_delim(char *s, const char *dir,
10511047 size_t _len ;
10521048 /* Behavior of strlcpy is undefined if dst and src overlap */
10531049 if (s == dir )
1054- _len = strlen (dir );
1050+ _len = strlen (dir );
10551051 else
1056- _len = strlcpy (s , dir , len );
1057- s [_len ] = delim ;
1058- s [_len + 1 ] = '\0' ;
1052+ _len = strlcpy (s , dir , len );
1053+ s [_len ++ ] = delim ;
1054+ s [_len ] = '\0' ;
10591055 if (path )
1060- return strlcat ( s , path , len );
1056+ _len += strlcpy ( s + _len , path , len - _len );
10611057 return _len ;
10621058}
10631059
@@ -1135,8 +1131,8 @@ size_t fill_pathname_abbreviate_special(char *s,
11351131
11361132 for (i = 0 ; candidates [i ]; i ++ )
11371133 {
1138- if (!string_is_empty (candidates [i ]) &&
1139- string_starts_with (in_path , candidates [i ]))
1134+ if ( !string_is_empty (candidates [i ])
1135+ && string_starts_with (in_path , candidates [i ]))
11401136 {
11411137 size_t _len = strlcpy (s , notations [i ], len );
11421138
@@ -1275,50 +1271,44 @@ static int get_pathname_num_slashes(const char *in_path)
12751271size_t fill_pathname_abbreviated_or_relative (char * s ,
12761272 const char * in_refpath , const char * in_path , size_t len )
12771273{
1274+ size_t _len ;
12781275 char in_path_conformed [PATH_MAX_LENGTH ];
12791276 char in_refpath_conformed [PATH_MAX_LENGTH ];
1280- char expanded_path [PATH_MAX_LENGTH ];
12811277 char absolute_path [PATH_MAX_LENGTH ];
12821278 char relative_path [PATH_MAX_LENGTH ];
1283- char abbreviated_path [PATH_MAX_LENGTH ];
12841279
1285- expanded_path [0 ] = '\0' ;
12861280 absolute_path [0 ] = '\0' ;
12871281 relative_path [0 ] = '\0' ;
1288- abbreviated_path [0 ] = '\0' ;
12891282
1290- strlcpy (in_path_conformed , in_path , sizeof (in_path_conformed ));
1283+ strlcpy (in_path_conformed , in_path , sizeof (in_path_conformed ));
12911284 strlcpy (in_refpath_conformed , in_refpath , sizeof (in_refpath_conformed ));
12921285
12931286 pathname_conform_slashes_to_os (in_path_conformed );
12941287 pathname_conform_slashes_to_os (in_refpath_conformed );
12951288
12961289 /* Expand paths which start with :\ to an absolute path */
1297- fill_pathname_expand_special (expanded_path ,
1298- in_path_conformed , sizeof (expanded_path ));
1290+ fill_pathname_expand_special (absolute_path ,
1291+ in_path_conformed , sizeof (absolute_path ));
12991292
13001293 /* Get the absolute path if it is not already */
1301- if (path_is_absolute (expanded_path ))
1302- strlcpy (absolute_path , expanded_path , PATH_MAX_LENGTH );
1303- else
1294+ if (!path_is_absolute (absolute_path ))
13041295 fill_pathname_resolve_relative (absolute_path ,
1305- in_refpath_conformed , in_path_conformed , PATH_MAX_LENGTH );
1306-
1296+ in_refpath_conformed , in_path_conformed ,
1297+ sizeof ( absolute_path ));
13071298 pathname_conform_slashes_to_os (absolute_path );
13081299
13091300 /* Get the relative path and see how many directories long it is */
13101301 path_relative_to (relative_path , absolute_path ,
13111302 in_refpath_conformed , sizeof (relative_path ));
13121303
13131304 /* Get the abbreviated path and see how many directories long it is */
1314- fill_pathname_abbreviate_special (abbreviated_path ,
1315- absolute_path , sizeof (abbreviated_path ));
1305+ _len = fill_pathname_abbreviate_special (s , absolute_path , len );
13161306
13171307 /* Use the shortest path, preferring the relative path*/
1318- if ( get_pathname_num_slashes (relative_path ) <=
1319- get_pathname_num_slashes (abbreviated_path ))
1308+ if ( get_pathname_num_slashes (relative_path )
1309+ <= get_pathname_num_slashes (s ))
13201310 return strlcpy (s , relative_path , len );
1321- return strlcpy ( s , abbreviated_path , len ) ;
1311+ return _len ;
13221312}
13231313
13241314/**
@@ -1395,7 +1385,7 @@ size_t fill_pathname_application_path(char *s, size_t len)
13951385 size_t _len = strlcpy (s , resolved_bundle_dir_buf , len - 1 );
13961386 s [ _len ] = '/' ;
13971387 s [++ _len ] = '\0' ;
1398- rv = _len ;
1388+ rv = _len ;
13991389 }
14001390 }
14011391#else
0 commit comments