mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-04-30 05:25:59 +00:00
change strtol:parse/2 to return a standard {ok,Result} 2-tuple
This commit is contained in:
@@ -1127,11 +1127,7 @@ read_ar_name(FP) ->
|
||||
"/" -> {ok, String}; % archive symbol table
|
||||
"//" -> {ok, String}; % archive string table
|
||||
[$/ | Numeral] -> % offset into archive string table
|
||||
case strtol:parse(Numeral, 10) of
|
||||
{ok, Value, []} -> {ok, Value};
|
||||
{ok, _Value, _} -> {error, trailing_garbage};
|
||||
{error, _Reason} = Error -> Error
|
||||
end;
|
||||
strtol(Numeral, 10);
|
||||
_ ->
|
||||
case string:split(String ++ "$", "/") of
|
||||
[FileName, "$"] -> {ok, FileName};
|
||||
@@ -1149,18 +1145,20 @@ read_ar_uid(FP) ->
|
||||
|
||||
read_number(FP, Base, FieldSize) ->
|
||||
case read_string(FP, FieldSize) of
|
||||
{ok, String} ->
|
||||
case strtol:parse(trim_trailing_spaces(String), Base) of
|
||||
{ok, Value, []} -> {ok, Value};
|
||||
{ok, _Value, _} -> {error, trailing_garbage};
|
||||
{error, _Reason} = Error -> Error
|
||||
end;
|
||||
{ok, String} -> strtol(trim_trailing_spaces(String), Base);
|
||||
{error, _Reason} = Error -> Error
|
||||
end.
|
||||
|
||||
trim_trailing_spaces(String) ->
|
||||
string:trim(String, trailing, [$\s]).
|
||||
|
||||
strtol(String, Base) ->
|
||||
case strtol:parse(String, Base) of
|
||||
{ok, {Value, _Rest = []}} -> {ok, Value};
|
||||
{ok, {_Value, _Rest}} -> {error, trailing_garbage};
|
||||
{error, _Reason} = Error -> Error
|
||||
end.
|
||||
|
||||
%% read FieldSize characters
|
||||
read_string(FP, FieldSize) ->
|
||||
case pdp10_stdio:fread(1, FieldSize, FP) of
|
||||
|
||||
Reference in New Issue
Block a user