Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clm
Commits
8a9bdfb0
Commit
8a9bdfb0
authored
Oct 17, 2003
by
John van Groningen
Browse files
add code for non-windows platforms
parent
26359b52
Changes
1
Hide whitespace changes
Inline
Side-by-side
htoclean/htoclean source code/htoclean.icl
View file @
8a9bdfb0
...
...
@@ -3,6 +3,8 @@ module htoclean;
import
StdEnv
;
import
fclc
;
/* for windows */
import
code
from
"program_args.o"
;
n_args
::
Int
;
...
...
@@ -15,16 +17,44 @@ program_arg i = code {
ccall
program_arg
"I-S"
}
DirectorySeparator
:==
'\\'
;
/* */
/*
n_args:==GetArgC;
program_arg i:==GetArgvN i;
GetArgC :: Int;
GetArgC = code {
ccall get_argc ":I"
}
GetArgvN :: !Int -> String;
GetArgvN n = code {
ccall get_argv_n "I:S"
}
DirectorySeparator :== '/';
*/
/* for macintosh
DirectorySeparator :== ':';
import mac_file_selector_carbon;
*/
split_path_name_in_file_and_directory_name
::
!{#
Char
}
->
(!{#
Char
},{#
Char
});
split_path_name_in_file_and_directory_name
path_name
#
last_
backslash_index
=
find_last_backslash
(
size
path_name
-1
);
#
last_
directory_separator_index
=
find_last_directory_separator
(
size
path_name
-1
);
with
{
find_last_
backslash
n
|
n
<
0
||
path_name
.[
n
]==
'\\'
find_last_
directory_separator
n
|
n
<
0
||
path_name
.[
n
]==
DirectorySeparator
=
n
;
=
find_last_
backslash
(
n
-1
);
=
find_last_
directory_separator
(
n
-1
);
}
=
(
path_name
%
(
0
,
last_
backslash
_index
),
path_name
%
(
last_
backslash
_index
+1
,
size
path_name
-1
));
=
(
path_name
%
(
0
,
last_
directory_separator
_index
),
path_name
%
(
last_
directory_separator
_index
+1
,
size
path_name
-1
));
write_errors
[]
stdio
=
stdio
;
...
...
@@ -36,27 +66,40 @@ write_errors [HError string line:l] stdio
=
write_errors
l
stdio
;
wait_for_keypress
w
/* for windows and mac */
#
(
stdio
,
w
)
=
stdio
w
;
stdio
=
stdio
<<<
"Press any key to exit"
;
(
ok
,
c
,
stdio
)
=
freadc
stdio
;
(
ok
,
w
)
=
fclose
stdio
w
;
=
w
;
force_file_io
file
w
:==
snd
(
fclose
file
w
);
//force_file_io :: !.File !*World -> World; force_file_io file w = w; //Solaris and Linux
Start
w
/* not for macintosh */
#
n_arguments
=
n_args
;
|
n_arguments
<>
2
#
stderr
=
fwrites
"Usage: htoclean h_file_name
\n
"
stderr
;
stderr
=
fwrites
"Generates a .icl and .dcl file for a c header file
\n
"
stderr
;
(
ok
,
w
)
=
fclose
stderr
w
;
w
=
force_file_io
stderr
w
;
=
wait_for_keypress
w
;
#
path_name
=
program_arg
1
;
(
directory_name
,
file_name
)
=
split_path_name_in_file_and_directory_name
path_name
;
/* */
/* for macintosh
# (stdio_,w) = stdio w;
stdio_ = stdio_ <<< "Select the C header file\n";
w = force_file_io stdio_ w;
(ok,path_name,w) = SelectInputFile w;
*/
#
(
directory_name
,
file_name
)
=
split_path_name_in_file_and_directory_name
path_name
;
h_file_name
=
if
(
file_name
%
(
size
file_name
-2
,
size
file_name
-1
)==
".h"
)
(
file_name
%
(
0
,
size
file_name
-3
))
file_name
;
(
errors
,
w
)
=
accFiles
(
compile_header
directory_name
h_file_name
)
w
;
=
case
errors
of
{
[]
->
w
;
_
#
(
stdio
,
w
)
=
stdio
w
;
stdio
=
write_errors
errors
stdio
;
(
ok
,
w
)
=
fclose
stdio
w
;
w
=
force_file_io
stdio
w
;
->
wait_for_keypress
w
;
};
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