geany
1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
![]() ![]() |
#include "general.h"
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <limits.h>
#include "debug.h"
#include "routines.h"
#include "routines_p.h"
#include <errno.h>
#include "vstring.h"
Go to the source code of this file.
Macros | |
#define | MB_LEN_MAX 6 |
#define | TMPDIR "/tmp" |
#define | S_ISLNK(mode) false /* assume no soft links */ |
#define | S_ISDIR(mode) false /* assume no soft links */ |
#define | S_IFMT 0 |
#define | S_IXUSR 0 |
#define | S_IXGRP 0 |
#define | S_IXOTH 0 |
#define | S_IRUSR 0400 |
#define | S_IWUSR 0200 |
#define | S_ISUID 0 |
#define | S_ISGID 0 |
#define | PATH_MAX 256 |
Functions | |
static bool | isPathSeparator (const int c) |
static char * | strSeparator (const char *s) |
static char * | strRSeparator (const char *s) |
static void | canonicalizePath (char *const path) |
void | freeRoutineResources (void) |
void | setExecutableName (const char *const path) |
const char * | getExecutableName (void) |
const char * | getExecutablePath (void) |
static bool | fnmChEq (int c1, int c2) |
void * | eMalloc (const size_t size) |
void * | eCalloc (const size_t count, const size_t size) |
void * | eRealloc (void *const ptr, const size_t size) |
void | eFree (void *const ptr) |
void | eFreeNoNullCheck (void *const ptr) |
void | eFreeIndirect (void **ptr) |
int | struppercmp (const char *s1, const char *s2) |
int | strnuppercmp (const char *s1, const char *s2, size_t n) |
char * | strstr (const char *str, const char *substr) |
char * | strrstr (const char *str, const char *substr) |
char * | eStrdup (const char *str) |
char * | eStrndup (const char *str, size_t len) |
void | toLowerString (char *str) |
void | toUpperString (char *str) |
char * | newLowerString (const char *str) |
char * | newUpperString (const char *str) |
bool | strToULong (const char *const str, int base, unsigned long *value) |
bool | strToLong (const char *const str, int base, long *value) |
bool | strToUInt (const char *const str, int base, unsigned int *value) |
bool | strToInt (const char *const str, int base, int *value) |
void | setCurrentDirectory (void) |
fileStatus * | eStat (const char *const fileName) |
void | eStatFree (fileStatus *status) |
bool | doesFileExist (const char *const fileName) |
bool | doesExecutableExist (const char *const fileName) |
bool | isRecursiveLink (const char *const dirName) |
bool | isSameFile (const char *const name1, const char *const name2) |
const char * | baseFilename (const char *const filePath) |
const char * | fileExtension (const char *const fileName) |
char * | baseFilenameSansExtensionNew (const char *const fileName, const char *const templateExt) |
bool | isAbsolutePath (const char *const path) |
char * | combinePathAndFile (const char *const path, const char *const file) |
static char * | concat (const char *s1, const char *s2, const char *s3) |
char * | absoluteFilename (const char *file) |
char * | absoluteDirname (char *file) |
char * | relativeFilename (const char *file, const char *dir) |
MIO * | tempFile (const char *const mode, char **const pName) |
Variables | |
char * | CurrentDirectory |
static const char * | ExecutableProgram |
static const char * | ExecutableName |
#define MB_LEN_MAX 6 |
Definition at line 29 of file routines.c.
#define PATH_MAX 256 |
Definition at line 137 of file routines.c.
#define S_IFMT 0 |
Definition at line 94 of file routines.c.
#define S_IRUSR 0400 |
Definition at line 108 of file routines.c.
#define S_ISDIR | ( | mode | ) | false /* assume no soft links */ |
Definition at line 89 of file routines.c.
#define S_ISGID 0 |
Definition at line 119 of file routines.c.
#define S_ISLNK | ( | mode | ) | false /* assume no soft links */ |
Definition at line 81 of file routines.c.
#define S_ISUID 0 |
Definition at line 115 of file routines.c.
#define S_IWUSR 0200 |
Definition at line 111 of file routines.c.
#define S_IXGRP 0 |
Definition at line 101 of file routines.c.
#define S_IXOTH 0 |
Definition at line 104 of file routines.c.
#define S_IXUSR 0 |
Definition at line 98 of file routines.c.
#define TMPDIR "/tmp" |
Definition at line 66 of file routines.c.
char * absoluteDirname | ( | char * | file | ) |
Definition at line 833 of file routines.c.
References absoluteFilename(), CurrentDirectory, eStrdup(), NULL, save, and strRSeparator().
Referenced by openTagFile().
char * absoluteFilename | ( | const char * | file | ) |
Definition at line 753 of file routines.c.
References canonicalizePath(), concat(), CurrentDirectory, eFree(), eStrdup(), isAbsolutePath(), isPathSeparator(), NULL, OUTPUT_PATH_SEPARATOR, and strSeparator().
Referenced by absoluteDirname(), isRecursiveLink(), isSameFile(), relativeFilename(), and setInputFileParametersCommon().
const char * baseFilename | ( | const char *const | filePath | ) |
Definition at line 608 of file routines.c.
References MB_LEN_MAX, NULL, strRSeparator(), and tail().
Referenced by baseFilenameSansExtensionNew(), fileExtension(), getFileLanguageForRequestInternal(), getLanguageForCommand(), getLanguageForFilename(), hackReject(), isExcludedFile(), makeFileTag(), setExecutableName(), and setOwnerDirectoryOfInputFile().
char * baseFilenameSansExtensionNew | ( | const char *const | fileName, |
const char *const | templateExt | ||
) |
Definition at line 666 of file routines.c.
References baseFilename(), eStrndup(), and NULL.
Referenced by getFileLanguageForRequestInternal().
|
static |
Definition at line 572 of file routines.c.
References isPathSeparator(), and OUTPUT_PATH_SEPARATOR.
Referenced by absoluteFilename(), isSameFile(), and setCurrentDirectory().
char * combinePathAndFile | ( | const char *const | path, |
const char *const | file | ||
) |
Definition at line 713 of file routines.c.
References isPathSeparator(), OUTPUT_PATH_SEPARATOR, vStringCatS(), vStringCopyS(), vStringDeleteUnwrap(), vStringNew(), and vStringPut().
Referenced by expandOnSearchPathList(), prependEnvvar(), and setSourceFileName().
|
static |
bool doesExecutableExist | ( | const char *const | fileName | ) |
Definition at line 501 of file routines.c.
References eStat(), fileStatus::exists, and fileStatus::isExecutable.
bool doesFileExist | ( | const char *const | fileName | ) |
Definition at line 495 of file routines.c.
References eStat(), and fileStatus::exists.
Referenced by expandOnOptlibPathList(), openTagFile(), processHeaderListOption(), and processTagRegexOption().
void * eCalloc | ( | const size_t | count, |
const size_t | size | ||
) |
Definition at line 228 of file routines.c.
References count, error(), FATAL, and NULL.
Referenced by createToken().
void eFree | ( | void *const | ptr | ) |
Definition at line 252 of file routines.c.
References Assert, NULL, and ptr.
Referenced by absoluteFilename(), addLanguageMap(), addTagRegexInternal(), addTagRegexOption(), ancestorClear(), argDelete(), argForth(), cArgDelete(), cArgForth(), clearParserFields(), closeTagFile(), colprintHeaderColumnDelete(), colprintTableDelete(), common_flag_field_long(), compileRegex(), copyBytes(), defineField(), defineScopeSeparator(), deleteChar(), deletePattern(), deletePoolToken(), deleteStatement(), deleteTable(), deleteTableEntry(), deleteTagEnry(), deleteToken(), eFreeIndirect(), endEtagsFile(), entry_destroy(), eStatFree(), expandOnSearchPathList(), fieldDefinitionDestroy(), fieldPatternDelete(), fileNameMatched(), fillGuestRequest(), finalizeDependencies(), findPascalTags(), findPythonTags(), flagsEval(), fmtDelete(), freeKdef(), freeKeywordTable(), freeKindControlBlock(), freeLineFposMap(), freeLregexControlBlock(), freeModifier(), freeParserResources(), freeRdef(), freeRoleControlBlock(), freeRoutineResources(), freeSlaveControlBlock(), freeString(), freeTagFileResources(), getFileLanguageForRequestInternal(), getMio(), getSpecLanguageCommon(), guestRequestDelete(), hashTableDelete(), initFieldObjects(), isCtagsLine(), isPodWord(), isRecursiveLink(), isSameFile(), isValidTagAddress(), kindFree(), makeDefineTag(), makePromise(), markTagExtraBitFull(), mio_new_file_full(), mio_new_mio(), mio_unref(), nestingLevelsFree(), nextFileLineSkippingComments(), objPoolDelete(), optlibFreeDep(), parseArglist(), parseFunction(), pickLanguageBySelection(), pre_ptrn_flag_advanceTo_long(), pre_ptrn_flag_mtable_long(), preload(), printLanguageList(), processKindsOption(), processLangDefineKind(), processLangDefineRole(), processLangKindRoleDefinition(), processLanguageDefineOption(), processLanguageMapOption(), processLanguageMultitableExtendingOption(), processLanguagesOption(), processMapOption(), processRolesOption(), ptrArrayDelete(), readIgnoreList(), relativeFilename(), removeLanguageMap(), renderFieldPattern(), replacementTruncate(), scopeSeparatorDelete(), tagFieldDelete(), testEtagsInvocation(), trashBoxDelete(), trashMakeEmpty(), trashPut(), trashTakeBack0(), uwiDeactivate(), vStringDelete(), vStringDeleteUnwrap(), vStringNewOwn(), and xtagDefinitionDestroy().
void eFreeIndirect | ( | void ** | ptr | ) |
Definition at line 263 of file routines.c.
References eFree(), NULL, and ptr.
Referenced by initFieldObjects(), initXtagObjects(), and langStackInit().
void eFreeNoNullCheck | ( | void *const | ptr | ) |
Definition at line 258 of file routines.c.
References ptr.
Referenced by freeRoleControlBlock(), getMio(), mio_new_mio(), and openTagFile().
void * eMalloc | ( | const size_t | size | ) |
Definition at line 218 of file routines.c.
References error(), FATAL, and NULL.
Referenced by defineField(), eRealloc(), getMio(), initFieldObjects(), and isPodWord().
void * eRealloc | ( | void *const | ptr, |
const size_t | size | ||
) |
Definition at line 238 of file routines.c.
References eMalloc(), error(), FATAL, NULL, and ptr.
Referenced by getMio(), mio_new_mio(), nestingLevelsPush(), and openTagFile().
fileStatus * eStat | ( | const char *const | fileName | ) |
Definition at line 455 of file routines.c.
References eStatFree(), eStrdup(), NULL, S_ISDIR, S_ISGID, S_ISLNK, S_ISUID, S_IXGRP, S_IXOTH, and S_IXUSR.
Referenced by closeInputFile(), createTagsForEntry(), doesExecutableExist(), doesFileExist(), getFileLanguageForRequestInternal(), getMio(), isRecursiveLink(), processOptionFileCommon(), and tempFile().
void eStatFree | ( | fileStatus * | status | ) |
Definition at line 486 of file routines.c.
References eFree(), fileStatus::name, and NULL.
Referenced by createTagsForEntry(), eStat(), getFileLanguageForRequestInternal(), getMio(), processOptionFileCommon(), and tempFile().
char * eStrdup | ( | const char * | str | ) |
Definition at line 327 of file routines.c.
References xMalloc.
Referenced by absoluteDirname(), absoluteFilename(), addCompiledTagPattern(), addExtensionList(), addRegexTable(), addTagRegexOption(), allocKindControlBlock(), attachParserField(), cArgRead(), common_flag_anonymous_long(), copyParserFields(), copyTagEntry(), cppGetSignature(), defineScopeSeparator(), eStat(), extractMapFromParameter(), fieldPatternNew(), flagsEval(), kindNew(), openTagFile(), OptlibParser(), parseKinds(), parseLongOption(), parserNew(), parseShortOption(), pre_lang_def_flag_base_long(), pre_ptrn_flag_advanceTo_long(), processLanguageDefineOption(), processLanguageMapOption(), processLanguagesOption(), processMapOption(), stringCopy(), and testEtagsInvocation().
char * eStrndup | ( | const char * | str, |
size_t | len | ||
) |
Definition at line 334 of file routines.c.
References xMalloc.
Referenced by addTagRegexOption(), baseFilenameSansExtensionNew(), common_flag_field_long(), common_flag_msg_long(), fillGuestRequest(), getLanguageComponentInOptionFull(), parseKinds(), parseLongOption(), pre_ptrn_flag_mtable_long(), processKindsOption(), processLangDefineExtra(), processLangDefineField(), processLangDefineKind(), processLangDefineRole(), processLangKindRoleDefinition(), processLanguageDefineOption(), processLanguageMultitableExtendingOption(), processListRolesOptions(), and processRolesOption().
const char * fileExtension | ( | const char *const | fileName | ) |
Definition at line 650 of file routines.c.
References baseFilename(), and NULL.
Referenced by getPatternLanguageAndSpec(), and isIncludeFile().
|
static |
Definition at line 205 of file routines.c.
Referenced by relativeFilename().
void freeRoutineResources | ( | void | ) |
Definition at line 180 of file routines.c.
References CurrentDirectory, eFree(), and NULL.
Referenced by ctags_cli_main().
const char * getExecutableName | ( | void | ) |
Definition at line 192 of file routines.c.
References ExecutableName.
Referenced by batchMakeTags(), notice(), printInvocationDescription(), stderrDefaultErrorPrinter(), and testEtagsInvocation().
const char * getExecutablePath | ( | void | ) |
Definition at line 197 of file routines.c.
References ExecutableProgram.
bool isAbsolutePath | ( | const char *const | path | ) |
Definition at line 684 of file routines.c.
References error(), FATAL, and isPathSeparator().
Referenced by absoluteFilename(), setInputFileParametersCommon(), and setSourceFileName().
|
static |
Definition at line 536 of file routines.c.
References NULL, and PATH_SEPARATOR.
Referenced by absoluteFilename(), canonicalizePath(), combinePathAndFile(), isAbsolutePath(), isRecursiveLink(), relativeFilename(), and setCurrentDirectory().
bool isRecursiveLink | ( | const char *const | dirName | ) |
Definition at line 507 of file routines.c.
References absoluteFilename(), eFree(), eStat(), isPathSeparator(), isSameFile(), fileStatus::isSymbolicLink, NULL, and strRSeparator().
Referenced by recurseIntoDirectory().
bool isSameFile | ( | const char *const | name1, |
const char *const | name2 | ||
) |
Definition at line 582 of file routines.c.
References absoluteFilename(), canonicalizePath(), eFree(), and strcasecmp.
Referenced by checkSameFile(), and isRecursiveLink().
char * newLowerString | ( | const char * | str | ) |
Definition at line 362 of file routines.c.
References xMalloc.
char * newUpperString | ( | const char * | str | ) |
char * relativeFilename | ( | const char * | file, |
const char * | dir | ||
) |
Definition at line 854 of file routines.c.
References absoluteFilename(), eFree(), fnmChEq(), isPathSeparator(), NULL, OUTPUT_PATH_SEPARATOR, strSeparator(), and xMalloc.
Referenced by setInputFileParametersCommon().
void setCurrentDirectory | ( | void | ) |
Definition at line 438 of file routines.c.
References canonicalizePath(), CurrentDirectory, isPathSeparator(), NULL, OUTPUT_PATH_SEPARATOR, PATH_MAX, and xMalloc.
Referenced by ctags_cli_main().
void setExecutableName | ( | const char *const | path | ) |
Definition at line 186 of file routines.c.
References baseFilename(), ExecutableName, and ExecutableProgram.
Referenced by ctags_cli_main().
int strnuppercmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | n | ||
) |
Definition at line 293 of file routines.c.
|
static |
Definition at line 556 of file routines.c.
References NULL, PATH_SEPARATOR, and strSeparator().
Referenced by absoluteDirname(), baseFilename(), and isRecursiveLink().
char * strrstr | ( | const char * | str, |
const char * | substr | ||
) |
|
static |
Definition at line 547 of file routines.c.
References PATH_SEPARATOR.
Referenced by absoluteFilename(), relativeFilename(), and strRSeparator().
char * strstr | ( | const char * | str, |
const char * | substr | ||
) |
Definition at line 304 of file routines.c.
References NULL.
Referenced by ada_suffix(), add_custom_filetype(), build_parse_make_dir(), build_replace_placeholder(), check_partial_completion(), colprintHeaderColumnNew(), createTag(), determineEmacsModeAtEOF(), determineEmacsModeAtFirstLine(), extractVimFileType(), find_triple_end(), findLuaTags(), findMatlabTags(), findVariable(), init_tag_from_file_ctags(), load_dialog_prefs(), on_config_file_clicked(), parse_compiler_error_line(), parseImports(), pm_tree_search(), pre_ptrn_flag_advanceTo_long(), read_named_style(), spawn_async_with_pipes(), tasteR(), tasteREXXOrDosBatch(), templates_replace_command(), testEtagsInvocation(), tm_source_file_read_tags_file(), truncateTagLineAfterTag(), ui_get_mime_icon(), utils_is_uri(), utils_strpos(), utils_strv_find_lcs(), utils_strv_shorten_file_list(), and utils_tidy_path().
bool strToInt | ( | const char *const | str, |
int | base, | ||
int * | value | ||
) |
Definition at line 423 of file routines.c.
References strToLong().
Referenced by pre_ptrn_flag_advanceTo_long(), pre_ptrn_flag_guest_long(), pre_ptrn_flag_mgroup_long(), and processForceQuitOption().
bool strToLong | ( | const char *const | str, |
int | base, | ||
long * | value | ||
) |
Definition at line 403 of file routines.c.
References errno.
Referenced by fmtNew(), processShortOption(), and strToInt().
bool strToUInt | ( | const char *const | str, |
int | base, | ||
unsigned int * | value | ||
) |
Definition at line 412 of file routines.c.
References strToULong().
Referenced by processPatternLengthLimit().
bool strToULong | ( | const char *const | str, |
int | base, | ||
unsigned long * | value | ||
) |
int struppercmp | ( | const char * | s1, |
const char * | s2 | ||
) |
Definition at line 283 of file routines.c.
Referenced by compareTagsFolded().
MIO * tempFile | ( | const char *const | mode, |
char **const | pName | ||
) |
Definition at line 896 of file routines.c.
References Assert, DEBUG_STATUS, debugPrintf(), DebugStatement, error(), eStat(), eStatFree(), ExecutableProgram, FATAL, fileStatus::isSetuid, mio_new_fp(), mkstemp(), name, NULL, open, OUTPUT_PATH_SEPARATOR, PERROR, S_IRUSR, S_IWUSR, TMPDIR, and xMalloc.
Referenced by beginEtagsFile(), openTagFile(), and replacementTruncate().
void toLowerString | ( | char * | str | ) |
Definition at line 342 of file routines.c.
Referenced by testEtagsInvocation().
void toUpperString | ( | char * | str | ) |
Definition at line 351 of file routines.c.
char* CurrentDirectory |
Definition at line 152 of file routines.c.
Referenced by absoluteDirname(), absoluteFilename(), freeRoutineResources(), openTagFile(), ptagMakeProcCwd(), and setCurrentDirectory().
|
static |
Definition at line 155 of file routines.c.
Referenced by getExecutableName(), and setExecutableName().
|
static |
Definition at line 154 of file routines.c.
Referenced by getExecutablePath(), setExecutableName(), and tempFile().