Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
thunar
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
268
Issues
268
List
Boards
Labels
Service Desk
Milestones
Custom Issue Tracker
Custom Issue Tracker
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xfce
thunar
Commits
dbcc8eb9
Commit
dbcc8eb9
authored
Mar 26, 2012
by
Peter de Ridder
Committed by
Jannis Pohlmann
Mar 26, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial attempt to implement hex sorting.
parent
0dca6e49
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
4 deletions
+42
-4
thunar/thunar-file.c
thunar/thunar-file.c
+42
-4
No files found.
thunar/thunar-file.c
View file @
dbcc8eb9
...
...
@@ -3218,6 +3218,10 @@ compare_by_name_using_number (const gchar *ap,
gchar
bc
;
guint
skipped_zeros_a
;
guint
skipped_zeros_b
;
const
gchar
*
original_ap
=
ap
;
const
gchar
*
original_bp
=
bp
;
gchar
hex_ac
;
gchar
hex_bc
;
/* up until now the numbers match. Now compare the numbers by digit
* count, the longest number is the largest. If the lengths are equal
...
...
@@ -3227,7 +3231,8 @@ compare_by_name_using_number (const gchar *ap,
skipped_zeros_a
=
skip_leading_zeros
(
&
ap
,
start_a
);
skipped_zeros_b
=
skip_leading_zeros
(
&
bp
,
start_b
);
/* determine the largest number */
/* advance until we've reached the end of the shorter one of the two
* number strings */
for
(
ai
=
ap
,
bi
=
bp
;;
++
ai
,
++
bi
)
{
ac
=
*
ai
;
...
...
@@ -3236,14 +3241,47 @@ compare_by_name_using_number (const gchar *ap,
break
;
}
/* if one of the numbers still has a digit, that number is the largest. */
/* check if the two strings are potential hex numbers */
if
(
g_ascii_isxdigit
(
ac
)
&&
g_ascii_isxdigit
(
bc
))
{
/* advance until we hit a non-hex character */
for
(
ai
=
original_ap
,
bi
=
original_bp
;;
++
ai
,
++
bi
)
{
hex_ac
=
*
ai
;
hex_bc
=
*
bi
;
if
(
!
g_ascii_isxdigit
(
hex_ac
)
||
!
g_ascii_isxdigit
(
hex_bc
))
break
;
}
/* check if both potential hex numbers end at the same offset */
if
(
!
g_ascii_isxdigit
(
hex_ac
)
&&
!
g_ascii_isxdigit
(
hex_bc
))
{
/* original_ap, original_bp either point to the first character where
* the two strings differ or to the character before that; in the second
* case we have to advance by one. after that we can perform an ASCII
* comparison on the first different character */
hex_ac
=
*
original_ap
;
hex_bc
=
*
original_bp
;
if
(
hex_ac
==
hex_bc
)
{
original_ap
+=
1
;
original_bp
+=
1
;
hex_ac
=
*
original_ap
;
hex_bc
=
*
original_bp
;
}
return
hex_ac
-
hex_bc
;
}
}
/* if one of the number strings continues while the other has already
* stopped at the current offset, that first number is larger */
if
(
g_ascii_isdigit
(
ac
))
return
1
;
else
if
(
g_ascii_isdigit
(
bc
))
return
-
1
;
/* both number
s have the same length. look for the first digit tha
t
* is different */
/* both number
strings have the same length. look for the first digi
t
*
that
is different */
for
(;;
++
ap
,
++
bp
)
{
ac
=
*
ap
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment