Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename USER_HOME_EXPAND to UserHomeExpand and add documentation #447

Merged
merged 1 commit into from
Jan 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions doc/ref/files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ or into <F>/home/myhome/gap</F>, respectively.
<#Include Label="DirectoryContents">
<#Include Label="DirectoryDesktop">
<#Include Label="DirectoryHome">

</Section>


Expand Down Expand Up @@ -475,6 +474,7 @@ can be used to get information about the error.
</Description>
</ManSection>

<#Include Label="UserHomeExpand">

<#Include Label="Reread">

Expand All @@ -485,4 +485,3 @@ can be used to get information about the error.
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<!-- %% -->
<!-- %E -->

19 changes: 19 additions & 0 deletions lib/files.gd
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,25 @@ end );
DeclareGlobalFunction( "Edit" );


#############################################################################
##
#F UserHomeExpand . . . . . . . . . . . . . expand leading ~ in file name
##
## <#GAPDoc Label="UserHomeExpand">
## <ManSection>
## <Func Name="UserHomeExpand" Arg='obj'/>
## <Description>
##
## Replaces "~" at the start of <A>obj</A> with the users home directory
## (which is stored in `GAPInfo.UserHome`, if known) and returns the result.
## If <A>obj</A> does not start with "~", the filename is returned unchanged.
## </Description>
## </ManSection>
## <#/GAPDoc>
##
DeclareGlobalFunction("UserHomeExpand");


# the character set definitions might be needed when processing files, thus
# they must come earlier.
BIND_GLOBAL("CHARS_DIGITS",Immutable(SSortedList("0123456789")));
Expand Down
12 changes: 12 additions & 0 deletions lib/files.gi
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ BindGlobal( "DirectoryType", NewType(
DirectoriesFamily,
IsDirectory and IsDirectoryRep ) );

#############################################################################
##
#F UserHomeExpand . . . . . . . . . . . . . expand leading ~ in file name
##

InstallGlobalFunction("UserHomeExpand", function(str)
if not IsString(str) then
ErrorMayQuit("Filenames must be a string");
fi;
return USER_HOME_EXPAND(str);
end);



#############################################################################
Expand Down
5 changes: 2 additions & 3 deletions lib/streams.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ DeclareOperation( "PrintFormattingStatus", [IsOutputStream] );
BIND_GLOBAL( "AppendTo", function( arg )
if IsString(arg[1]) then
arg := ShallowCopy(arg);
arg[1] := USER_HOME_EXPAND(arg[1]);
arg[1] := UserHomeExpand(arg[1]);
CallFuncList( APPEND_TO, arg );
elif IsOutputStream(arg[1]) then
# direct call to `WriteAll' if arg is one string and formatting
Expand Down Expand Up @@ -1037,7 +1037,7 @@ end );
BIND_GLOBAL( "PrintTo", function( arg )
if IsString(arg[1]) then
arg := ShallowCopy(arg);
arg[1] := USER_HOME_EXPAND(arg[1]);
arg[1] := UserHomeExpand(arg[1]);
CallFuncList( PRINT_TO, arg );
elif IsOutputStream(arg[1]) then
# direct call to `WriteAll' if arg is one string and formatting
Expand Down Expand Up @@ -1350,4 +1350,3 @@ DeclareGlobalFunction( "InputFromUser" );
#############################################################################
##
#E

15 changes: 1 addition & 14 deletions lib/string.g
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,8 @@ InstallMethod( String,


#############################################################################
## Documented as UserHomeExpand in files.gi
##
#F USER_HOME_EXPAND . . . . . . . . . . . . . expand leading ~ in file name
##
## <ManSection>
## <Func Name="USER_HOME_EXPAND" Arg='obj'/>
## <Description>
##
##
## If `GAPInfo.UserHome' has positive length then a leading '~' character in
## string `str' is substituted by the content of `GAPInfo.UserHome'.
## Otherwise `str' itself is returned.
## </Description>
## </ManSection>
##
BIND_GLOBAL("USER_HOME_EXPAND", function(str)
if Length(str) > 0 and str[1] = '~' and IsString(GAPInfo.UserHome) and
Length( GAPInfo.UserHome ) > 0 then
Expand All @@ -347,7 +335,6 @@ BIND_GLOBAL("USER_HOME_EXPAND", function(str)
return str;
fi;
end);


#############################################################################
##
Expand Down