Mercurial > octave
comparison src/user-prefs.cc @ 1613:f18871f4df2b
[project @ 1995-11-03 12:06:56 by jwe]
author | jwe |
---|---|
date | Fri, 03 Nov 1995 12:12:36 +0000 |
parents | 27f5ac98fc4a |
children | 50e71230d582 |
comparison
equal
deleted
inserted
replaced
1612:004842061dcf | 1613:f18871f4df2b |
---|---|
23 | 23 |
24 #ifdef HAVE_CONFIG_H | 24 #ifdef HAVE_CONFIG_H |
25 #include <config.h> | 25 #include <config.h> |
26 #endif | 26 #endif |
27 | 27 |
28 #include <cstdio> | |
29 #include <cstdlib> | |
28 #include <cstring> | 30 #include <cstring> |
29 | 31 |
30 #include "error.h" | 32 #include "error.h" |
31 #include "gripes.h" | 33 #include "gripes.h" |
32 #include "mappers.h" | 34 #include "mappers.h" |
78 | 80 |
79 user_pref.completion_append_char = '\0'; | 81 user_pref.completion_append_char = '\0'; |
80 | 82 |
81 user_pref.default_save_format = 0; | 83 user_pref.default_save_format = 0; |
82 user_pref.editor = 0; | 84 user_pref.editor = 0; |
85 user_pref.exec_path = 0; | |
83 user_pref.gnuplot_binary = 0; | 86 user_pref.gnuplot_binary = 0; |
84 user_pref.imagepath = 0; | 87 user_pref.imagepath = 0; |
85 user_pref.info_file = 0; | 88 user_pref.info_file = 0; |
89 user_pref.info_prog = 0; | |
86 user_pref.loadpath = 0; | 90 user_pref.loadpath = 0; |
87 user_pref.pager_binary = 0; | 91 user_pref.pager_binary = 0; |
88 user_pref.ps1 = 0; | 92 user_pref.ps1 = 0; |
89 user_pref.ps2 = 0; | 93 user_pref.ps2 = 0; |
90 user_pref.ps4 = 0; | 94 user_pref.ps4 = 0; |
722 | 726 |
723 return status; | 727 return status; |
724 } | 728 } |
725 | 729 |
726 int | 730 int |
731 sv_exec_path (void) | |
732 { | |
733 int status = 0; | |
734 | |
735 char *exec_path = builtin_string_variable ("EXEC_PATH"); | |
736 if (exec_path) | |
737 { | |
738 char *arch_dir = octave_arch_lib_dir (); | |
739 char *bin_dir = octave_bin_dir (); | |
740 | |
741 int len = strlen (arch_dir) + strlen (bin_dir) + strlen (SEPCHAR_STR); | |
742 | |
743 static char *putenv_cmd = 0; | |
744 | |
745 delete [] putenv_cmd; | |
746 | |
747 putenv_cmd = 0; | |
748 | |
749 int eplen = strlen (exec_path); | |
750 | |
751 if (eplen > 0) | |
752 { | |
753 int prepend = (exec_path[0] == ':'); | |
754 int append = (eplen > 1 && exec_path[eplen-1] == ':'); | |
755 | |
756 if (prepend) | |
757 { | |
758 if (append) | |
759 { | |
760 putenv_cmd = new char [2 * len + eplen + 6]; | |
761 sprintf (putenv_cmd, | |
762 "PATH=%s" SEPCHAR_STR "%s%s%s" SEPCHAR_STR "%s", | |
763 arch_dir, bin_dir, exec_path, arch_dir, bin_dir); | |
764 } | |
765 else | |
766 { | |
767 putenv_cmd = new char [len + eplen + 6]; | |
768 sprintf (putenv_cmd, | |
769 "PATH=%s" SEPCHAR_STR "%s%s", | |
770 arch_dir, bin_dir, exec_path); | |
771 } | |
772 } | |
773 else | |
774 { | |
775 if (append) | |
776 { | |
777 putenv_cmd = new char [len + eplen + 6]; | |
778 sprintf (putenv_cmd, | |
779 "PATH=%s%s" SEPCHAR_STR "%s", | |
780 exec_path, arch_dir, bin_dir); | |
781 } | |
782 else | |
783 { | |
784 putenv_cmd = new char [len + eplen + 6]; | |
785 sprintf (putenv_cmd, "PATH=%s", exec_path); | |
786 } | |
787 } | |
788 } | |
789 else | |
790 { | |
791 putenv_cmd = new char [len+6]; | |
792 sprintf (putenv_cmd, "PATH=%s" SEPCHAR_STR "%s", arch_dir, bin_dir); | |
793 } | |
794 | |
795 putenv (putenv_cmd); | |
796 } | |
797 else | |
798 { | |
799 gripe_invalid_value_specified ("EXEC_PATH"); | |
800 status = -1; | |
801 } | |
802 | |
803 return status; | |
804 } | |
805 | |
806 int | |
727 sv_gnuplot_binary (void) | 807 sv_gnuplot_binary (void) |
728 { | 808 { |
729 int status = 0; | 809 int status = 0; |
730 | 810 |
731 char *s = builtin_string_variable ("gnuplot_binary"); | 811 char *s = builtin_string_variable ("gnuplot_binary"); |
775 user_pref.info_file = s; | 855 user_pref.info_file = s; |
776 } | 856 } |
777 else | 857 else |
778 { | 858 { |
779 gripe_invalid_value_specified ("INFO_FILE"); | 859 gripe_invalid_value_specified ("INFO_FILE"); |
860 status = -1; | |
861 } | |
862 | |
863 return status; | |
864 } | |
865 | |
866 int | |
867 sv_info_prog (void) | |
868 { | |
869 int status = 0; | |
870 | |
871 char *s = builtin_string_variable ("INFO_PROGRAM"); | |
872 if (s) | |
873 { | |
874 delete [] user_pref.info_prog; | |
875 user_pref.info_prog = s; | |
876 } | |
877 else | |
878 { | |
879 gripe_invalid_value_specified ("INFO_PROGRAM"); | |
780 status = -1; | 880 status = -1; |
781 } | 881 } |
782 | 882 |
783 return status; | 883 return status; |
784 } | 884 } |