diff options
60 files changed, 33899 insertions, 1 deletions
diff --git a/.Xresources b/.Xresources new file mode 100644 index 0000000..f01da72 --- /dev/null +++ b/.Xresources @@ -0,0 +1,3 @@ +*vt100.translations: #override \n\ + Ctrl ~Shift <Key>Tab: string(0x1b) string("[27;5;9~") \n \ + Ctrl Shift <Key>Tab: string(0x1b) string("[27;6;9~") \n diff --git a/.vim/README.csupport b/.vim/README.csupport new file mode 100644 index 0000000..34cc02c --- /dev/null +++ b/.vim/README.csupport @@ -0,0 +1,185 @@ +README for c.vim (Version 5.10) / February 05 2010 + + * DESCRIPTION + * INSTALLATION + * RELEASE NOTES + * FILES + * ADDITIONAL TIPS + * CREDITS + +================================================================================ + DESCRIPTION +================================================================================ +C/C++-IDE for Vim/gVim. It is written to considerably speed up writing code in +a consistent style. This is done by inserting complete statements, idioms, +code snippets, templates, and comments. Syntax checking, compiling, running a +program, running indent or code checkers can be done with a keystroke. There +are many additional hints and options which can improve speed and comfort when +writing C/C++. See the help file csupport.txt for more information. + +================================================================================ + INSTALLATION +================================================================================ +The subdirectories in the zip archive cvim.zip mirror the directory structure +which is needed below the local installation directory $HOME/.vim/ for +LINUX/UNIX ($VIM/vimfiles/ for Windows; find the value of $VIM with ":echo +$VIM" from inside Vim). + +(0) Save the template files in '$HOME/.vim/c-support/templates/Templates' if + you have changed any of them. + +(1) Copy the zip archive cvim.zip to $HOME/.vim and run + + unzip cvim.zip + + If you have already an older version of bash-support and you have modified + the template files you may want to save your templates first and suppress + overwriting them with + + unzip cvim.zip -x *Templates *.template + +(2) Loading of plugin files must be enabled. If not use + + :filetype plugin on + + This is the minimal content of the file '$HOME/.vimrc'. Create one if there + is none. + +(3) Set at least some personal details in the file + '$HOME/.vim/c-support/templates/Templates' + (file '$VIM\c-support/templates/Templates' under Windows). Here is the + minimal personalization (my settings as an example): + + |AUTHOR| = Dr. Fritz Mehner + |AUTHORREF| = fgm + |EMAIL| = mehner@fh-swf.de + |COMPANY| = FH Südwestfalen, Iserlohn + |COPYRIGHT| = Copyright (c) |YEAR|, |AUTHOR| + + (Read more about the template system in the plugin documentation) + +(4) Consider additional settings in the file '$HOME/.vimrc'. + The files customization.vimrc and customization.gvimrc are replacements or + extensions for your .vimrc and .gvimrc ( _vimrc and _gvimrc under Windows). + You may want to use parts of them. The files are documented. + +There are a lot of features and options which can be used and influenced: + + * use of template files and tags + * surround marked blocks with statements + * using and managing personal code snippets + * generate/remove multiline comments + * picking up prototypes + * C/C++ dictionaries for keyword completion + * (re)moving the root menu + +Restart gVim/Vim generate the help tags + + :helptags ~/.vim/doc + +and look at csupport help with + + :help csupport + +or use the 'help' item in the root menu of this plug-in. + + +-----------------------------------------------+ + | +-------------------------------------------+ | + | | ** PLEASE READ THE DOCUMENTATION ** | | + | | Actions differ for different modes! | | + | +-------------------------------------------+ | + +-----------------------------------------------+ + +Any problems ? See the TROUBLESHOOTING section at the end of the help file +'doc/csupport.txt'. + +================================================================================ + RELEASE NOTES FOR VERSION 5.10 +================================================================================ +- The plugin now handles different template styles without editing and + reloading the main template file. +- The number of template styles is not limited. +- New hotkey and ex-command to switch template styles. +- Template styles can automatically be related to file extensions. +- indent(1) errors will be presented in a quickfix error window. +- Comment alignment improved. +- Minor improvements. + + OLDER RELEASE NOTES : see file 'ChangeLog' + +================================================================================ + FILES +================================================================================ + +README.csupport This file. + +doc/csupport.txt The help file for the local on-line help. + +ftplugin/c.vim A file type plug-in. Define hotkeys, creates a + local dictionary for each C/C++ file. + +plugin/c.vim The C/C++ plug-in for GVIM. + +c-support/scripts/wrapper.sh The wrapper script for the use of a xterm. +c-support/templates/* C-style and C++-style template files + (see csupport.txt on how to adapt the templates). + + +c-support/wordlists/c-c++-keywords.list All C and C++ keywords (also in word.list). +c-support/wordlists/k+r.list K&R-Book: Words from the table of content. + They appear frequently in comments. +c-support/wordlists/stl_index.list STL: method and type names. + + +-------------------------- --------------------------------------------------- + The following files and extensions are for + convenience only. c.vim will work without them. + --------------------------------------------------- +c-support/doc/c-hotkeys.pdf Hotkey reference card. +c-support/doc/ChangeLog The change log. + +rc/customization.ctags Additional settings I use in .ctags to enable + navigation through makefiles ans qmake files with + the plug-in taglist.vim. + +rc/customization.gvimrc Additional settings I use in .gvimrc : + hot keys, mouse settings, ... The file is + commented. Append it to your .gvimrc if you like. + +rc/customization.indent.pro Additional settings I use in .indent.pro : + See the indent manual. + +rc/customization.vimrc Additional settings I use in .vimrc : incremental + search, tabstop, hot keys, font, use of + dictionaries, ... The file is commented. Append + it to your .vimrc if you like. + +================================================================================ + CREDITS +================================================================================ + + Some ideas are taken from the following documents: + + 1. Recommended C Style and Coding Standards (Indian Hill Style Guide) + www.doc.ic.ac.uk/lab/secondyear/cstyle/cstyle.html + 2. Programming in C++, Ellemtel Telecommunication Systems Laboratories + www.it.bton.ac.uk/burks/burks/language/cpp/cppstyle/ellhome.htm + 3. C++ Coding Standard, Todd Hoff + www.possibility.com/Cpp/CppCodingStandard.html + + The splint error format is taken from the file splint.vim (Vim standard + distribution). + +------------------ + + ... finally + +Johann Wolfgang von Goethe (1749-1832), the greatest of the German poets, +about LINUX, Vim/gVim and other great tools (Ok, almost.) : + + Ein Mann, der recht zu wirken denkt, Who on efficient work is bent, + Muß auf das beste Werkzeug halten. Must choose the fittest instrument. + +Faust, Teil 1, Vorspiel auf dem Theater Faust, Part 1, Prologue for the Theatre + +================================================================================ diff --git a/.vim/after/ftplugin/c.vim b/.vim/after/ftplugin/c.vim new file mode 100644 index 0000000..66dfc5e --- /dev/null +++ b/.vim/after/ftplugin/c.vim @@ -0,0 +1,2 @@ +" OmniCppComplete initialization +call omni#cpp#complete#Init() diff --git a/.vim/after/ftplugin/cpp.vim b/.vim/after/ftplugin/cpp.vim new file mode 100644 index 0000000..66dfc5e --- /dev/null +++ b/.vim/after/ftplugin/cpp.vim @@ -0,0 +1,2 @@ +" OmniCppComplete initialization +call omni#cpp#complete#Init() diff --git a/.vim/after/syntax/help.vim b/.vim/after/syntax/help.vim new file mode 100755 index 0000000..bd7a073 --- /dev/null +++ b/.vim/after/syntax/help.vim @@ -0,0 +1,114 @@ +"***************************************************************************** +"** Name: help.vim - extend standard syntax highlighting for help ** +"** ** +"** Type: syntax file ** +"** ** +"** Author: Christian Habermann ** +"** christian (at) habermann-net (point) de ** +"** ** +"** Copyright: (c) 2002-2004 by Christian Habermann ** +"** ** +"** License: GNU General Public License 2 (GPL 2) or later ** +"** ** +"** This program is free software; you can redistribute it ** +"** and/or modify it under the terms of the GNU General Public ** +"** License as published by the Free Software Foundation; either ** +"** version 2 of the License, or (at your option) any later ** +"** version. ** +"** ** +"** This program is distributed in the hope that it will be ** +"** useful, but WITHOUT ANY WARRANTY; without even the implied ** +"** warrenty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ** +"** PURPOSE. ** +"** See the GNU General Public License for more details. ** +"** ** +"** Version: 1.0.1 ** +"** tested under Linux and Win32, VIM and GVIM 6.2 ** +"** ** +"** History: 0.1.0 12. Dec. 2002 - 21. Feb. 2003 ** +"** initial version, not released ** +"** 1.0.0 6. Apr. 2003 ** +"** no changes, first release ** +"** 1.0.1 3. Mar. 2004 ** +"** marker changed from 0xa7 to $ in order to avoid problems ** +"** with fonts that use codes > 0x7f as multibyte characters ** +"** (e.g. Chinese, Korean, Japanese... fonts) ** +"** ** +"** ** +"***************************************************************************** +"** Description: ** +"** This syntax file extends the standard syntax highlighting for help ** +"** files. This is needed in order to view the C-reference manual ** +"** of the project CRefVim correctly. ** +"** This syntax file is only active for the help file named ** +"** "crefvim.txt". For other help files no extention on syntax ** +"** highlighting is applied. ** +"** ** +"** For futher information see crefvimdoc.txt or do :help crefvimdoc ** +"** ** +"** Happy viming... ** +"***************************************************************************** + + +" extend syntax-highlighting for "crefvim.txt" only (not case-sensitive) + +if tolower(expand("%:t"))=="crefvim.txt" + syn match helpCRVSubStatement "statement[0-9Ns]*" contained + syn match helpCRVSubCondition "condition[0-9]*" contained + syn match helpCRVSubExpression "expression[0-9]*" contained + syn match helpCRVSubExpr "expr[0-9N]" contained + syn match helpCRVSubType "type-name" contained + syn match helpCRVSubIdent "identifier" contained + syn match helpCRVSubIdentList "identifier-list" contained + syn match helpCRVSubOperand "operand[0-9]*" contained + syn match helpCRVSubConstExpr "constant-expression[1-9Ns]*" contained + syn match helpCRVSubClassSpec "storage-class-specifier" contained + syn match helpCRVSubTypeSpec "type-specifier" contained + syn match helpCRVSubEnumList "enumerator-list" contained + syn match helpCRVSubDecl "declarator" contained + syn match helpCRVSubRetType "return-type" contained + syn match helpCRVSubFuncName "function-name" contained + syn match helpCRVSubParamList "parameter-list" contained + syn match helpCRVSubReplList "replacement-list" contained + syn match helpCRVSubNewLine "newline" contained + syn match helpCRVSubMessage "message" contained + syn match helpCRVSubFilename "filename" contained + syn match helpCRVSubDigitSeq "digit-sequence" contained + syn match helpCRVSubMacroNames "macro-name[s]*" contained + syn match helpCRVSubDirective "directive" contained + + + syn match helpCRVignore "\$[a-zA-Z0-9\\\*/\._=()\-+%<>&\^|!~\?:,\[\];{}#\'\" ]\+\$" contains=helpCRVstate + syn match helpCRVstate "[a-zA-Z0-9\\\*/\._=()\-+%<>&\^|!~\?:,\[\];{}#\'\" ]\+" contained contains=helpCRVSub.* + + + hi helpCRVitalic term=italic cterm=italic gui=italic + + hi def link helpCRVstate Comment + hi def link helpCRVSubStatement helpCRVitalic + hi def link helpCRVSubCondition helpCRVitalic + hi def link helpCRVSubExpression helpCRVitalic + hi def link helpCRVSubExpr helpCRVitalic + hi def link helpCRVSubOperand helpCRVitalic + hi def link helpCRVSubType helpCRVitalic + hi def link helpCRVSubIdent helpCRVitalic + hi def link helpCRVSubIdentList helpCRVitalic + hi def link helpCRVSubConstExpr helpCRVitalic + hi def link helpCRVSubClassSpec helpCRVitalic + hi def link helpCRVSubTypeSpec helpCRVitalic + hi def link helpCRVSubEnumList helpCRVitalic + hi def link helpCRVSubDecl helpCRVitalic + hi def link helpCRVSubRetType helpCRVitalic + hi def link helpCRVSubFuncName helpCRVitalic + hi def link helpCRVSubParamList helpCRVitalic + hi def link helpCRVSubReplList helpCRVitalic + hi def link helpCRVSubNewLine helpCRVitalic + hi def link helpCRVSubMessage helpCRVitalic + hi def link helpCRVSubFilename helpCRVitalic + hi def link helpCRVSubDigitSeq helpCRVitalic + hi def link helpCRVSubMacroNames helpCRVitalic + hi def link helpCRVSubDirective helpCRVitalic + hi def link helpCRVignore Ignore +endif + +" vim: ts=8 sw=2 diff --git a/.vim/autoload/omni/common/debug.vim b/.vim/autoload/omni/common/debug.vim new file mode 100644 index 0000000..eded649 --- /dev/null +++ b/.vim/autoload/omni/common/debug.vim @@ -0,0 +1,32 @@ +" Description: Omni completion debug functions +" Maintainer: Vissale NEANG +" Last Change: 26 sept. 2007 + +let s:CACHE_DEBUG_TRACE = [] + +" Start debug, clear the debug file +function! omni#common#debug#Start() + let s:CACHE_DEBUG_TRACE = [] + call extend(s:CACHE_DEBUG_TRACE, ['============ Debug Start ============']) + call writefile(s:CACHE_DEBUG_TRACE, "Omni.dbg") +endfunc + +" End debug, write to debug file +function! omni#common#debug#End() + call extend(s:CACHE_DEBUG_TRACE, ["============= Debug End ============="]) + call extend(s:CACHE_DEBUG_TRACE, [""]) + call writefile(s:CACHE_DEBUG_TRACE, "Omni.dbg") +endfunc + +" Debug trace function +function! omni#common#debug#Trace(szFuncName, ...) + let szTrace = a:szFuncName + let paramNum = a:0 + if paramNum>0 + let szTrace .= ':' + endif + for i in range(paramNum) + let szTrace = szTrace .' ('. string(eval('a:'.string(i+1))).')' + endfor + call extend(s:CACHE_DEBUG_TRACE, [szTrace]) +endfunc diff --git a/.vim/autoload/omni/common/utils.vim b/.vim/autoload/omni/common/utils.vim new file mode 100644 index 0000000..c880ad2 --- /dev/null +++ b/.vim/autoload/omni/common/utils.vim @@ -0,0 +1,67 @@ +" Description: Omni completion utils +" Maintainer: Vissale NEANG +" Last Change: 26 sept. 2007 + +" For sort numbers in list +function! omni#common#utils#CompareNumber(i1, i2) + let num1 = eval(a:i1) + let num2 = eval(a:i2) + return num1 == num2 ? 0 : num1 > num2 ? 1 : -1 +endfunc + +" TagList function calling the vim taglist() with try catch +" The only throwed exception is 'TagList:UserInterrupt' +" We also force the noignorecase option to avoid linear search when calling +" taglist() +function! omni#common#utils#TagList(szTagQuery) + let result = [] + let bUserIgnoreCase = &ignorecase + " Forcing noignorecase search => binary search can be used in taglist() + " if tags in the tag file are sorted + if bUserIgnoreCase + set noignorecase + endif + try + let result = taglist(a:szTagQuery) + catch /^Vim:Interrupt$/ + " Restoring user's setting + if bUserIgnoreCase + set ignorecase + endif + throw 'TagList:UserInterrupt' + catch + "Note: it seems that ctags can generate corrupted files, in this case + "taglist() will fail to read the tagfile and an exception from + "has_add() is thrown + endtry + + " Restoring user's setting + if bUserIgnoreCase + set ignorecase + endif + return result +endfunc + +" Same as TagList but don't throw exception +function! omni#common#utils#TagListNoThrow(szTagQuery) + let result = [] + try + let result = omni#common#utils#TagList(a:szTagQuery) + catch + endtry + return result +endfunc + +" Get the word under the cursor +function! omni#common#utils#GetWordUnderCursor() + let szLine = getline('.') + let startPos = getpos('.')[2]-1 + let startPos = (startPos < 0)? 0 : startPos + if szLine[startPos] =~ '\w' + let startPos = searchpos('\<\w\+', 'cbn', line('.'))[1] - 1 + endif + + let startPos = (startPos < 0)? 0 : startPos + let szResult = matchstr(szLine, '\w\+', startPos) + return szResult +endfunc diff --git a/.vim/autoload/omni/cpp/complete.vim b/.vim/autoload/omni/cpp/complete.vim new file mode 100644 index 0000000..a7e4edc --- /dev/null +++ b/.vim/autoload/omni/cpp/complete.vim @@ -0,0 +1,569 @@ +" Description: Omni completion script for cpp files +" Maintainer: Vissale NEANG +" Last Change: 27 sept. 2007 + +if v:version < 700 + echohl WarningMsg + echomsg "omni#cpp#complete.vim: Please install vim 7.0 or higher for omni-completion" + echohl None + finish +endif + +call omni#cpp#settings#Init() +let s:OmniCpp_ShowScopeInAbbr = g:OmniCpp_ShowScopeInAbbr +let s:OmniCpp_ShowPrototypeInAbbr = g:OmniCpp_ShowPrototypeInAbbr +let s:OmniCpp_ShowAccess = g:OmniCpp_ShowAccess +let s:szCurrentWorkingDir = getcwd() + +" Cache data +let s:CACHE_TAG_POPUP_ITEMS = {} +let s:CACHE_TAG_FILES = {} +let s:CACHE_TAG_ENV = '' +let s:CACHE_OVERLOADED_FUNCTIONS = {} + +" Has preview window? +let s:hasPreviewWindow = match(&completeopt, 'preview')>=0 +let s:hasPreviewWindowOld = s:hasPreviewWindow + +" Popup item list +let s:popupItemResultList = [] + +" May complete indicator +let s:bMayComplete = 0 + +" Init mappings +function! omni#cpp#complete#Init() + call omni#cpp#settings#Init() + set omnifunc=omni#cpp#complete#Main + inoremap <expr> <C-X><C-O> omni#cpp#maycomplete#Complete() + inoremap <expr> . omni#cpp#maycomplete#Dot() + inoremap <expr> > omni#cpp#maycomplete#Arrow() + inoremap <expr> : omni#cpp#maycomplete#Scope() +endfunc + +" Find the start position of the completion +function! s:FindStartPositionOfCompletion() + " Locate the start of the item, including ".", "->" and "[...]". + let line = getline('.') + let start = col('.') - 1 + + let lastword = -1 + while start > 0 + if line[start - 1] =~ '\w' + let start -= 1 + elseif line[start - 1] =~ '\.' + " Searching for dot '.' + if lastword == -1 + let lastword = start + endif + let start -= 1 + elseif start > 1 && line[start - 2] == '-' && line[start - 1] == '>' + " Searching for '->' + if lastword == -1 + let lastword = start + endif + let start -= 2 + elseif start > 1 && line[start - 2] == ':' && line[start - 1] == ':' + " Searching for '::' for namespaces and class + if lastword == -1 + let lastword = start + endif + let start -= 2 + elseif line[start - 1] == ']' + " Skip over [...]. + let n = 0 + let start -= 1 + while start > 0 + let start -= 1 + if line[start] == '[' + if n == 0 + break + endif + let n -= 1 + elseif line[start] == ']' " nested [] + let n += 1 + endif + endwhile + else + break + endif + endwhile + if lastword==-1 + " For completion on the current scope + let lastword = start + endif + return lastword +endfunc + +" Returns if szKey1.szKey2 is in the cache +" @return +" - 0 = key not found +" - 1 = szKey1.szKey2 found +" - 2 = szKey1.[part of szKey2] found +function! s:IsCached(cache, szKey1, szKey2) + " Searching key in the result cache + let szResultKey = a:szKey1 . a:szKey2 + let result = [0, szResultKey] + if a:szKey2 != '' + let szKey = a:szKey2 + while len(szKey)>0 + if has_key(a:cache, a:szKey1 . szKey) + let result[1] = a:szKey1 . szKey + if szKey != a:szKey2 + let result[0] = 2 + else + let result[0] = 1 + endif + break + endif + let szKey = szKey[:-2] + endwhile + else + if has_key(a:cache, szResultKey) + let result[0] = 1 + endif + endif + return result +endfunc + +" Extend a tag item to a popup item +function! s:ExtendTagItemToPopupItem(tagItem, szTypeName) + let tagItem = a:tagItem + + " Add the access + let szItemMenu = '' + let accessChar = {'public': '+','protected': '#','private': '-'} + if g:OmniCpp_ShowAccess + if has_key(tagItem, 'access') && has_key(accessChar, tagItem.access) + let szItemMenu = szItemMenu.accessChar[tagItem.access] + else + let szItemMenu = szItemMenu." " + endif + endif + + " Formating optional menu string we extract the scope information + let szName = substitute(tagItem.name, '.*::', '', 'g') + let szItemWord = szName + let szAbbr = szName + + if !g:OmniCpp_ShowScopeInAbbr + let szScopeOfTag = omni#cpp#utils#ExtractScope(tagItem) + let szItemMenu = szItemMenu.' '.szScopeOfTag[2:] + let szItemMenu = substitute(szItemMenu, '\s\+$', '', 'g') + else + let szAbbr = tagItem.name + endif + if g:OmniCpp_ShowAccess + let szItemMenu = substitute(szItemMenu, '^\s\+$', '', 'g') + else + let szItemMenu = substitute(szItemMenu, '\(^\s\+\)\|\(\s\+$\)', '', 'g') + endif + + " Formating information for the preview window + if index(['f', 'p'], tagItem.kind[0])>=0 + let szItemWord .= '(' + if g:OmniCpp_ShowPrototypeInAbbr && has_key(tagItem, 'signature') + let szAbbr .= tagItem.signature + else + let szAbbr .= '(' + endif + endif + let szItemInfo = '' + if s:hasPreviewWindow + let szItemInfo = omni#cpp#utils#GetPreviewWindowStringFromTagItem(tagItem) + endif + + " If a function is a ctor we add a new key in the tagItem + if index(['f', 'p'], tagItem.kind[0])>=0 + if match(szName, '^\~') < 0 && a:szTypeName =~ '\C\<'.szName.'$' + " It's a ctor + let tagItem['ctor'] = 1 + elseif has_key(tagItem, 'access') && tagItem.access == 'friend' + " Friend function + let tagItem['friendfunc'] = 1 + endif + endif + + " Extending the tag item to a popup item + let tagItem['word'] = szItemWord + let tagItem['abbr'] = szAbbr + let tagItem['menu'] = szItemMenu + let tagItem['info'] = szItemInfo + let tagItem['dup'] = (s:hasPreviewWindow && index(['f', 'p', 'm'], tagItem.kind[0])>=0) + return tagItem +endfunc + +" Get tag popup item list +function! s:TagPopupList(szTypeName, szBase) + let result = [] + + " Searching key in the result cache + let cacheResult = s:IsCached(s:CACHE_TAG_POPUP_ITEMS, a:szTypeName, a:szBase) + + " Building the tag query, we don't forget dtors when a:szBase=='' + if a:szTypeName!='' + " Scope search + let szTagQuery = '^' . a:szTypeName . '::' . a:szBase . '\~\?\w\+$' + else + " Global search + let szTagQuery = '^' . a:szBase . '\w\+$' + endif + + " If the result is already in the cache we return it + if cacheResult[0] + let result = s:CACHE_TAG_POPUP_ITEMS[ cacheResult[1] ] + if cacheResult[0] == 2 + let result = filter(copy(result), 'v:val.name =~ szTagQuery' ) + endif + return result + endif + + try + " Getting tags + let result = omni#common#utils#TagList(szTagQuery) + + " We extend tag items to popup items + call map(result, 's:ExtendTagItemToPopupItem(v:val, a:szTypeName)') + + " We store the result in a cache + if cacheResult[1] != '' + let s:CACHE_TAG_POPUP_ITEMS[ cacheResult[1] ] = result + endif + catch /^TagList:UserInterrupt$/ + endtry + + return result +endfunc + +" Find complete matches for a completion on the global scope +function! s:SearchGlobalMembers(szBase) + if a:szBase != '' + let tagPopupList = s:TagPopupList('', a:szBase) + let tagPopupList = filter(copy(tagPopupList), g:omni#cpp#utils#szFilterGlobalScope) + call extend(s:popupItemResultList, tagPopupList) + endif +endfunc + +" Search class, struct, union members +" @param resolvedTagItem: a resolved tag item +" @param szBase: string base +" @return list of tag items extended to popup items +function! s:SearchMembers(resolvedTagItem, szBase) + let result = [] + if a:resolvedTagItem == {} + return result + endif + + " Get type info without the starting '::' + let szTagName = omni#cpp#utils#ExtractTypeInfoFromTag(a:resolvedTagItem)[2:] + + " Unnamed type case. A tag item representing an unnamed type is a variable + " ('v') a member ('m') or a typedef ('t') + if index(['v', 't', 'm'], a:resolvedTagItem.kind[0])>=0 && has_key(a:resolvedTagItem, 'typeref') + " We remove the 'struct:' or 'class:' etc... + let szTagName = substitute(a:resolvedTagItem.typeref, '^\w\+:', '', 'g') + endif + + return copy(s:TagPopupList(szTagName, a:szBase)) +endfunc + +" Return if the tag env has changed +function! s:HasTagEnvChanged() + if s:CACHE_TAG_ENV == &tags + return 0 + else + let s:CACHE_TAG_ENV = &tags + return 1 + endif +endfunc + +" Return if a tag file has changed in tagfiles() +function! s:HasATagFileOrTagEnvChanged() + if s:HasTagEnvChanged() + let s:CACHE_TAG_FILES = {} + return 1 + endif + + let result = 0 + for tagFile in tagfiles() + if tagFile == "" + continue + endif + + if has_key(s:CACHE_TAG_FILES, tagFile) + let currentFiletime = getftime(tagFile) + if currentFiletime > s:CACHE_TAG_FILES[tagFile] + " The file has changed, updating the cache + let s:CACHE_TAG_FILES[tagFile] = currentFiletime + let result = 1 + endif + else + " We store the time of the file + let s:CACHE_TAG_FILES[tagFile] = getftime(tagFile) + let result = 1 + endif + endfor + return result +endfunc +" Initialization +call s:HasATagFileOrTagEnvChanged() + +" Filter same function signatures of base classes +function! s:FilterOverloadedFunctions(tagPopupList) + let result = [] + for tagPopupItem in a:tagPopupList + if has_key(tagPopupItem, 'kind') && index(['f', 'p'], tagPopupItem.kind[0])>=0 && has_key(tagPopupItem, 'signature') + if !has_key(s:CACHE_OVERLOADED_FUNCTIONS, tagPopupItem.word . tagPopupItem.signature) + let s:CACHE_OVERLOADED_FUNCTIONS[tagPopupItem.word . tagPopupItem.signature] = 1 + call extend(result, [tagPopupItem]) + endif + else + call extend(result, [tagPopupItem]) + endif + endfor + return result +endfunc + +" Access filter +function! s:GetAccessFilter(szFilter, szAccessFilter) + let szFilter = a:szFilter + if g:OmniCpp_DisplayMode == 0 + if a:szAccessFilter == 'public' + " We only get public members + let szFilter .= "&& v:val.access == 'public'" + elseif a:szAccessFilter == 'protected' + " We get public and protected members + let szFilter .= "&& v:val.access != 'private'" + endif + endif + return szFilter +endfunc + +" Filter class members in the popup menu after a completion with -> or . +function! s:FilterClassMembers(tagPopupList, szAccessFilter) + let szFilter = "(!has_key(v:val, 'friendfunc') && !has_key(v:val, 'ctor') && has_key(v:val, 'kind') && index(['m', 'p', 'f'], v:val.kind[0])>=0 && has_key(v:val, 'access'))" + call filter(a:tagPopupList, s:GetAccessFilter(szFilter, a:szAccessFilter)) + call extend(s:popupItemResultList, s:FilterOverloadedFunctions(a:tagPopupList)) +endfunc + +" Filter class scope members in the popup menu after a completion with :: +" We only display attribute and functions members that +" have an access information. We also display nested +" class, struct, union, and enums, typedefs +function! s:FilterClassScopeMembers(tagPopupList, szAccessFilter) + let szFilter = "!has_key(v:val, 'friendfunc') && has_key(v:val, 'kind') && (index(['m', 'p', 'f'], v:val.kind[0])>=0 && has_key(v:val, 'access'))" + let szFilter = s:GetAccessFilter(szFilter, a:szAccessFilter) + let szFilter .= "|| index(['c','e','g','s','t','u'], v:val.kind[0])>=0" + call filter(a:tagPopupList, szFilter) + call extend(s:popupItemResultList, s:FilterOverloadedFunctions(a:tagPopupList)) +endfunc + +" Filter static class members in the popup menu +function! s:FilterStaticClassMembers(tagPopupList, szAccessFilter) + let szFilter = "!has_key(v:val, 'friendfunc') && has_key(v:val, 'kind') && (index(['m', 'p', 'f'], v:val.kind[0])>=0 && has_key(v:val, 'access') && match(v:val.cmd, '\\Cstatic')!=-1)" + let szFilter = s:GetAccessFilter(szFilter, a:szAccessFilter) + let szFilter = szFilter . "|| index(['c','e','g','n','s','t','u','v'], v:val.kind[0])>=0" + call filter(a:tagPopupList, szFilter) + call extend(s:popupItemResultList, s:FilterOverloadedFunctions(a:tagPopupList)) +endfunc + +" Filter scope members in the popup menu +function! s:FilterNamespaceScopeMembers(tagPopupList) + call extend(s:popupItemResultList, a:tagPopupList) +endfunc + +" Init data at the start of completion +function! s:InitComplete() + " Reset the popup item list + let s:popupItemResultList = [] + let s:CACHE_OVERLOADED_FUNCTIONS = {} + + " Reset includes cache when the current working directory has changed + let szCurrentWorkingDir = getcwd() + if s:szCurrentWorkingDir != szCurrentWorkingDir + let s:szCurrentWorkingDir = szCurrentWorkingDir + let g:omni#cpp#includes#CACHE_INCLUDES = {} + let g:omni#cpp#includes#CACHE_FILE_TIME = {} + endif + + " Has preview window ? + let s:hasPreviewWindow = match(&completeopt, 'preview')>=0 + + let bResetCache = 0 + + " Reset tag env or tag files dependent caches + if s:HasATagFileOrTagEnvChanged() + let bResetCache = 1 + endif + + if (s:OmniCpp_ShowScopeInAbbr != g:OmniCpp_ShowScopeInAbbr) + \|| (s:OmniCpp_ShowPrototypeInAbbr != g:OmniCpp_ShowPrototypeInAbbr) + \|| (s:OmniCpp_ShowAccess != g:OmniCpp_ShowAccess) + + let s:OmniCpp_ShowScopeInAbbr = g:OmniCpp_ShowScopeInAbbr + let s:OmniCpp_ShowPrototypeInAbbr = g:OmniCpp_ShowPrototypeInAbbr + let s:OmniCpp_ShowAccess = g:OmniCpp_ShowAccess + let bResetCache = 1 + endif + + if s:hasPreviewWindow != s:hasPreviewWindowOld + let s:hasPreviewWindowOld = s:hasPreviewWindow + let bResetCache = 1 + endif + + if bResetCache + let g:omni#cpp#namespaces#CacheResolve = {} + let s:CACHE_TAG_POPUP_ITEMS = {} + let g:omni#cpp#utils#CACHE_TAG_INHERITS = {} + call garbagecollect() + endif + + " Check for updates + for szIncludeName in keys(g:omni#cpp#includes#CACHE_INCLUDES) + let fTime = getftime(szIncludeName) + let bNeedUpdate = 0 + if has_key(g:omni#cpp#includes#CACHE_FILE_TIME, szIncludeName) + if fTime != g:omni#cpp#includes#CACHE_FILE_TIME[szIncludeName] + let bNeedUpdate = 1 + endif + else + let g:omni#cpp#includes#CACHE_FILE_TIME[szIncludeName] = fTime + let bNeedUpdate = 1 + endif + + if bNeedUpdate + " We have to update include list and namespace map of this file + call omni#cpp#includes#GetList(szIncludeName, 1) + call omni#cpp#namespaces#GetMapFromBuffer(szIncludeName, 1) + endif + endfor + + let s:bDoNotComplete = 0 +endfunc + + +" This function is used for the 'omnifunc' option. +function! omni#cpp#complete#Main(findstart, base) + if a:findstart + "call omni#common#debug#Start() + + call s:InitComplete() + + " Note: if s:bMayComplete==1 g:omni#cpp#items#data is build by MayComplete functions + if !s:bMayComplete + " If the cursor is in a comment we go out + if omni#cpp#utils#IsCursorInCommentOrString() + " Returning -1 is not enough we have to set a variable to let + " the second call of omni#cpp#complete knows that the + " cursor was in a comment + " Why is there a second call when the first call returns -1 ? + let s:bDoNotComplete = 1 + return -1 + endif + + " We get items here (whend a:findstart==1) because GetItemsToComplete() + " depends on the cursor position. + " When a:findstart==0 the cursor position is modified + let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction()) + endif + + " Get contexts stack + let s:contextStack = omni#cpp#namespaces#GetContexts() + + " Reinit of may complete indicator + let s:bMayComplete = 0 + return s:FindStartPositionOfCompletion() + endif + + " If the cursor is in a comment we return an empty result + if s:bDoNotComplete + let s:bDoNotComplete = 0 + return [] + endif + + if len(g:omni#cpp#items#data)==0 + " A) CURRENT_SCOPE_COMPLETION_MODE + + " 1) Displaying data of each context + let szAccessFilter = 'all' + for szCurrentContext in s:contextStack + if szCurrentContext == '::' + continue + endif + + let resolvedTagItem = omni#cpp#utils#GetResolvedTagItem(s:contextStack, omni#cpp#utils#CreateTypeInfo(szCurrentContext)) + if resolvedTagItem != {} + " We don't search base classes because bases classes are + " already in the context stack + let tagPopupList = s:SearchMembers(resolvedTagItem, a:base) + if index(['c','s'], resolvedTagItem.kind[0])>=0 + " It's a class or struct + call s:FilterClassScopeMembers(tagPopupList, szAccessFilter) + let szAccessFilter = 'protected' + else + " It's a namespace or union, we display all members + call s:FilterNamespaceScopeMembers(tagPopupList) + endif + endif + endfor + + " 2) Displaying global scope members + if g:OmniCpp_GlobalScopeSearch + call s:SearchGlobalMembers(a:base) + endif + else + let typeInfo = omni#cpp#items#ResolveItemsTypeInfo(s:contextStack, g:omni#cpp#items#data) + + if typeInfo != {} + if g:omni#cpp#items#data[-1].kind == 'itemScope' + " B) SCOPE_COMPLETION_MODE + if omni#cpp#utils#GetTypeInfoString(typeInfo)=='' + call s:SearchGlobalMembers(a:base) + else + for resolvedTagItem in omni#cpp#utils#GetResolvedTags(s:contextStack, typeInfo) + let tagPopupList = s:SearchMembers(resolvedTagItem, a:base) + if index(['c','s'], resolvedTagItem.kind[0])>=0 + let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTag(resolvedTagItem) + if g:OmniCpp_DisplayMode==0 + " We want to complete a class or struct + " If this class is a base class so we display all class members + if index(s:contextStack, szTypeInfo)<0 + let szAccessFilter = 'public' + call s:FilterStaticClassMembers(tagPopupList, szAccessFilter) + else + let szAccessFilter = (s:contextStack[0] == szTypeInfo)? 'all' : 'protected' + call s:FilterClassScopeMembers(tagPopupList, szAccessFilter) + endif + else + if index(s:contextStack, szTypeInfo)<0 + let szAccessFilter = 'public' + else + let szAccessFilter = (s:contextStack[0] == szTypeInfo)? 'all' : 'protected' + endif + call s:FilterClassScopeMembers(tagPopupList, szAccessFilter) + endif + else + " We want to complete a namespace + call s:FilterNamespaceScopeMembers(tagPopupList) + endif + endfor + endif + else + " C) CLASS_MEMBERS_COMPLETION_MODE + for resolvedTagItem in omni#cpp#utils#GetResolvedTags(s:contextStack, typeInfo) + let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTag(resolvedTagItem) + if index(s:contextStack, szTypeInfo)<0 + let szAccessFilter = 'public' + else + let szAccessFilter = (s:contextStack[0] == szTypeInfo)? 'all' : 'protected' + endif + call s:FilterClassMembers(s:SearchMembers(resolvedTagItem, a:base), szAccessFilter) + endfor + endif + endif + endif + + "call omni#common#debug#End() + + return s:popupItemResultList +endfunc diff --git a/.vim/autoload/omni/cpp/includes.vim b/.vim/autoload/omni/cpp/includes.vim new file mode 100644 index 0000000..10a89bc --- /dev/null +++ b/.vim/autoload/omni/cpp/includes.vim @@ -0,0 +1,126 @@ +" Description: Omni completion script for cpp files +" Maintainer: Vissale NEANG +" Last Change: 26 sept. 2007 + +let g:omni#cpp#includes#CACHE_INCLUDES = {} +let g:omni#cpp#includes#CACHE_FILE_TIME = {} + +let s:rePreprocIncludePart = '\C#\s*include\s*' +let s:reIncludeFilePart = '\(<\|"\)\(\f\|\s\)\+\(>\|"\)' +let s:rePreprocIncludeFile = s:rePreprocIncludePart . s:reIncludeFilePart + +" Get the include list of a file +function! omni#cpp#includes#GetList(...) + if a:0 > 0 + return s:GetIncludeListFromFile(a:1, (a:0 > 1)? a:2 : 0 ) + else + return s:GetIncludeListFromCurrentBuffer() + endif +endfunc + +" Get the include list from the current buffer +function! s:GetIncludeListFromCurrentBuffer() + let listIncludes = [] + let originalPos = getpos('.') + + call setpos('.', [0, 1, 1, 0]) + let curPos = [1,1] + let alreadyInclude = {} + while curPos != [0,0] + let curPos = searchpos('\C\(^'.s:rePreprocIncludeFile.'\)', 'W') + if curPos != [0,0] + let szLine = getline('.') + let startPos = curPos[1] + let endPos = matchend(szLine, s:reIncludeFilePart, startPos-1) + if endPos!=-1 + let szInclusion = szLine[startPos-1:endPos-1] + let szIncludeFile = substitute(szInclusion, '\('.s:rePreprocIncludePart.'\)\|[<>""]', '', 'g') + let szResolvedInclude = omni#cpp#utils#ResolveFilePath(szIncludeFile) + + " Protection over self inclusion + if szResolvedInclude != '' && szResolvedInclude != omni#cpp#utils#ResolveFilePath(getreg('%')) + let includePos = curPos + if !has_key(alreadyInclude, szResolvedInclude) + call extend(listIncludes, [{'pos' : includePos, 'include' : szResolvedInclude}]) + let alreadyInclude[szResolvedInclude] = 1 + endif + endif + endif + endif + endwhile + + call setpos('.', originalPos) + return listIncludes +endfunc + +" Get the include list from a file +function! s:GetIncludeListFromFile(szFilePath, bUpdate) + let listIncludes = [] + if a:szFilePath == '' + return listIncludes + endif + + if !a:bUpdate && has_key(g:omni#cpp#includes#CACHE_INCLUDES, a:szFilePath) + return copy(g:omni#cpp#includes#CACHE_INCLUDES[a:szFilePath]) + endif + + let g:omni#cpp#includes#CACHE_FILE_TIME[a:szFilePath] = getftime(a:szFilePath) + + let szFixedPath = escape(a:szFilePath, g:omni#cpp#utils#szEscapedCharacters) + execute 'silent! lvimgrep /\C\(^'.s:rePreprocIncludeFile.'\)/gj '.szFixedPath + + let listQuickFix = getloclist(0) + let alreadyInclude = {} + for qf in listQuickFix + let szLine = qf.text + let startPos = qf.col + let endPos = matchend(szLine, s:reIncludeFilePart, startPos-1) + if endPos!=-1 + let szInclusion = szLine[startPos-1:endPos-1] + let szIncludeFile = substitute(szInclusion, '\('.s:rePreprocIncludePart.'\)\|[<>""]', '', 'g') + let szResolvedInclude = omni#cpp#utils#ResolveFilePath(szIncludeFile) + + " Protection over self inclusion + if szResolvedInclude != '' && szResolvedInclude != a:szFilePath + let includePos = [qf.lnum, qf.col] + if !has_key(alreadyInclude, szResolvedInclude) + call extend(listIncludes, [{'pos' : includePos, 'include' : szResolvedInclude}]) + let alreadyInclude[szResolvedInclude] = 1 + endif + endif + endif + endfor + + let g:omni#cpp#includes#CACHE_INCLUDES[a:szFilePath] = listIncludes + + return copy(listIncludes) +endfunc + +" For debug purpose +function! omni#cpp#includes#Display() + let szPathBuffer = omni#cpp#utils#ResolveFilePath(getreg('%')) + call s:DisplayIncludeTree(szPathBuffer, 0) +endfunc + +" For debug purpose +function! s:DisplayIncludeTree(szFilePath, indent, ...) + let includeGuard = {} + if a:0 >0 + let includeGuard = a:1 + endif + let szFilePath = omni#cpp#utils#ResolveFilePath(a:szFilePath) + if has_key(includeGuard, szFilePath) + return + else + let includeGuard[szFilePath] = 1 + endif + + let szIndent = repeat(' ', a:indent) + echo szIndent . a:szFilePath + let incList = omni#cpp#includes#GetList(a:szFilePath) + for inc in incList + call s:DisplayIncludeTree(inc.include, a:indent+1, includeGuard) + endfor +endfunc + + diff --git a/.vim/autoload/omni/cpp/items.vim b/.vim/autoload/omni/cpp/items.vim new file mode 100644 index 0000000..b943ad4 --- /dev/null +++ b/.vim/autoload/omni/cpp/items.vim @@ -0,0 +1,660 @@ +" Description: Omni completion script for cpp files +" Maintainer: Vissale NEANG +" Last Change: 26 sept. 2007 + +" Build the item list of an instruction +" An item is an instruction between a -> or . or ->* or .* +" We can sort an item in different kinds: +" eg: ((MyClass1*)(pObject))->_memberOfClass1.get() ->show() +" | cast | | member | | method | | method | +" @return a list of item +" an item is a dictionnary where keys are: +" tokens = list of token +" kind = itemVariable|itemCast|itemCppCast|itemTemplate|itemFunction|itemUnknown|itemThis|itemScope +function! omni#cpp#items#Get(tokens, ...) + let bGetWordUnderCursor = (a:0>0)? a:1 : 0 + + let result = [] + let itemsDelimiters = ['->', '.', '->*', '.*'] + + let tokens = reverse(omni#cpp#utils#BuildParenthesisGroups(a:tokens)) + + " fsm states: + " 0 = initial state + " TODO: add description of fsm states + let state=(bGetWordUnderCursor)? 1 : 0 + let item = {'tokens' : [], 'kind' : 'itemUnknown'} + let parenGroup=-1 + for token in tokens + if state==0 + if index(itemsDelimiters, token.value)>=0 + let item = {'tokens' : [], 'kind' : 'itemUnknown'} + let state = 1 + elseif token.value=='::' + let state = 9 + let item.kind = 'itemScope' + " Maybe end of tokens + elseif token.kind =='cppOperatorPunctuator' + " If it's a cppOperatorPunctuator and the current token is not + " a itemsDelimiters or '::' we can exit + let state=-1 + break + endif + elseif state==1 + call insert(item.tokens, token) + if token.kind=='cppWord' + " It's an attribute member or a variable + let item.kind = 'itemVariable' + let state = 2 + " Maybe end of tokens + elseif token.value=='this' + let item.kind = 'itemThis' + let state = 2 + " Maybe end of tokens + elseif token.value==')' + let parenGroup = token.group + let state = 3 + elseif token.value==']' + let parenGroup = token.group + let state = 4 + elseif token.kind == 'cppDigit' + let state = -1 + break + endif + elseif state==2 + if index(itemsDelimiters, token.value)>=0 + call insert(result, item) + let item = {'tokens' : [], 'kind' : 'itemUnknown'} + let state = 1 + elseif token.value == '::' + call insert(item.tokens, token) + " We have to get namespace or classscope + let state = 8 + " Maybe end of tokens + else + call insert(result, item) + let state=-1 + break + endif + elseif state==3 + call insert(item.tokens, token) + if token.value=='(' && token.group == parenGroup + let state = 5 + " Maybe end of tokens + endif + elseif state==4 + call insert(item.tokens, token) + if token.value=='[' && token.group == parenGroup + let state = 1 + endif + elseif state==5 + if token.kind=='cppWord' + " It's a function or method + let item.kind = 'itemFunction' + call insert(item.tokens, token) + let state = 2 + " Maybe end of tokens + elseif token.value == '>' + " Maybe a cpp cast or template + let item.kind = 'itemTemplate' + call insert(item.tokens, token) + let parenGroup = token.group + let state = 6 + else + " Perhaps it's a C cast eg: ((void*)(pData)) or a variable eg:(*pData) + let item.kind = omni#cpp#utils#GetCastType(item.tokens) + let state=-1 + call insert(result, item) + break + endif + elseif state==6 + call insert(item.tokens, token) + if token.value == '<' && token.group == parenGroup + " Maybe a cpp cast or template + let state = 7 + endif + elseif state==7 + call insert(item.tokens, token) + if token.kind=='cppKeyword' + " It's a cpp cast + let item.kind = omni#cpp#utils#GetCastType(item.tokens) + let state=-1 + call insert(result, item) + break + else + " Template ? + let state=-1 + call insert(result, item) + break + endif + elseif state==8 + if token.kind=='cppWord' + call insert(item.tokens, token) + let state = 2 + " Maybe end of tokens + else + let state=-1 + call insert(result, item) + break + endif + elseif state==9 + if token.kind == 'cppWord' + call insert(item.tokens, token) + let state = 10 + " Maybe end of tokens + else + let state=-1 + call insert(result, item) + break + endif + elseif state==10 + if token.value == '::' + call insert(item.tokens, token) + let state = 9 + " Maybe end of tokens + else + let state=-1 + call insert(result, item) + break + endif + endif + endfor + + if index([2, 5, 8, 9, 10], state)>=0 + if state==5 + let item.kind = omni#cpp#utils#GetCastType(item.tokens) + endif + call insert(result, item) + endif + + return result +endfunc + +" Resolve type information of items +" @param namespaces: list of namespaces used in the file +" @param szCurrentClassScope: the current class scope, only used for the first +" item to detect if this item is a class member (attribute, method) +" @param items: list of item, can be an empty list @see GetItemsToComplete +function! omni#cpp#items#ResolveItemsTypeInfo(contextStack, items) + " Note: kind = itemVariable|cCast|cppCast|template|function|itemUnknown|this + " For the first item, if it's a variable we try to detect the type of the + " variable with the function searchdecl. If it fails, thanks to the + " current class scope, we try to detect if the variable is an attribute + " member. + " If the kind of the item is a function, we have to first check if the + " function is a method of the class, if it fails we try to get a match in + " the global namespace. After that we get the returned type of the + " function. + " It the kind is a C cast or C++ cast, there is no problem, it's the + " easiest case. We just extract the type of the cast. + + let szCurrentContext = '' + let typeInfo = {} + " Note: We search the decl only for the first item + let bSearchDecl = 1 + for item in a:items + let curItem = item + if index(['itemVariable', 'itemFunction'], curItem.kind)>=0 + " Note: a variable can be : MyNs::MyClass::_var or _var or (*pVar) + " or _var[0][0] + let szSymbol = s:GetSymbol(curItem.tokens) + + " If we have MyNamespace::myVar + " We add MyNamespace in the context stack set szSymbol to myVar + if match(szSymbol, '::\w\+$') >= 0 + let szCurrentContext = substitute(szSymbol, '::\w\+$', '', 'g') + let szSymbol = matchstr(szSymbol, '\w\+$') + endif + let tmpContextStack = a:contextStack + if szCurrentContext != '' + let tmpContextStack = [szCurrentContext] + a:contextStack + endif + + if curItem.kind == 'itemVariable' + let typeInfo = s:GetTypeInfoOfVariable(tmpContextStack, szSymbol, bSearchDecl) + else + let typeInfo = s:GetTypeInfoOfReturnedType(tmpContextStack, szSymbol) + endif + + elseif curItem.kind == 'itemThis' + if len(a:contextStack) + let typeInfo = omni#cpp#utils#CreateTypeInfo(substitute(a:contextStack[0], '^::', '', 'g')) + endif + elseif curItem.kind == 'itemCast' + let typeInfo = omni#cpp#utils#CreateTypeInfo(s:ResolveCCast(curItem.tokens)) + elseif curItem.kind == 'itemCppCast' + let typeInfo = omni#cpp#utils#CreateTypeInfo(s:ResolveCppCast(curItem.tokens)) + elseif curItem.kind == 'itemScope' + let typeInfo = omni#cpp#utils#CreateTypeInfo(substitute(s:TokensToString(curItem.tokens), '\s', '', 'g')) + endif + + if omni#cpp#utils#IsTypeInfoValid(typeInfo) + let szCurrentContext = omni#cpp#utils#GetTypeInfoString(typeInfo) + endif + let bSearchDecl = 0 + endfor + + return typeInfo +endfunc + +" Get symbol name +function! s:GetSymbol(tokens) + let szSymbol = '' + let state = 0 + for token in a:tokens + if state == 0 + if token.value == '::' + let szSymbol .= token.value + let state = 1 + elseif token.kind == 'cppWord' + let szSymbol .= token.value + let state = 2 + " Maybe end of token + endif + elseif state == 1 + if token.kind == 'cppWord' + let szSymbol .= token.value + let state = 2 + " Maybe end of token + else + " Error + break + endif + elseif state == 2 + if token.value == '::' + let szSymbol .= token.value + let state = 1 + else + break + endif + endif + endfor + return szSymbol +endfunc + +" Search a declaration. +" eg: std::map +" can be empty +" Note: The returned type info can be a typedef +" The typedef resolution is done later +" @return +" - a dictionnary where keys are +" - type: the type of value same as type() +" - value: the value +function! s:GetTypeInfoOfVariable(contextStack, szVariable, bSearchDecl) + let result = {} + + if a:bSearchDecl + " Search type of declaration + "let result = s:SearchTypeInfoOfDecl(a:szVariable) + let result = s:SearchDecl(a:szVariable) + endif + + if result=={} + let szFilter = "index(['m', 'v'], v:val.kind[0])>=0" + let tagItem = s:ResolveSymbol(a:contextStack, a:szVariable, szFilter) + if tagItem=={} + return result + endif + + let szCmdWithoutVariable = substitute(omni#cpp#utils#ExtractCmdFromTagItem(tagItem), '\C\<'.a:szVariable.'\>.*', '', 'g') + let tokens = omni#cpp#tokenizer#Tokenize(omni#cpp#utils#GetCodeFromLine(szCmdWithoutVariable)) + let result = omni#cpp#utils#CreateTypeInfo(omni#cpp#utils#ExtractTypeInfoFromTokens(tokens)) + " TODO: Namespace resolution for result + + if result != {} && result.value=='' + " result.value=='' + " eg: + " struct + " { + " }gVariable; + if has_key(tagItem, 'typeref') + " Maybe the variable is a global var of an + " unnamed class, struct or union. + " eg: + " 1) + " struct + " { + " }gVariable; + " In this case we need the tags (the patched version) + " Note: We can have a named type like this: + " 2) + " class A + " { + " }gVariable; + if s:IsUnnamedType(tagItem) + " It's an unnamed type we are in the case 1) + let result = omni#cpp#utils#CreateTypeInfo(tagItem) + else + " It's not an unnamed type we are in the case 2) + + " eg: tagItem.typeref = 'struct:MY_STRUCT::MY_SUBSTRUCT' + let szTypeRef = substitute(tagItem.typeref, '^\w\+:', '', '') + + " eg: szTypeRef = 'MY_STRUCT::MY_SUBSTRUCT' + let result = omni#cpp#utils#CreateTypeInfo(szTypeRef) + endif + endif + endif + endif + return result +endfunc + +" Get the type info string from the returned type of function +function! s:GetTypeInfoOfReturnedType(contextStack, szFunctionName) + let result = {} + + let szFilter = "index(['f', 'p'], v:val.kind[0])>=0" + let tagItem = s:ResolveSymbol(a:contextStack, a:szFunctionName, szFilter) + + if tagItem != {} + let szCmdWithoutVariable = substitute(omni#cpp#utils#ExtractCmdFromTagItem(tagItem), '\C\<'.a:szFunctionName.'\>.*', '', 'g') + let tokens = omni#cpp#tokenizer#Tokenize(omni#cpp#utils#GetCodeFromLine(szCmdWithoutVariable)) + let result = omni#cpp#utils#CreateTypeInfo(omni#cpp#utils#ExtractTypeInfoFromTokens(tokens)) + " TODO: Namespace resolution for result + return result + endif + return result +endfunc + +" Resolve a symbol, return a tagItem +" Gets the first symbol found in the context stack +function! s:ResolveSymbol(contextStack, szSymbol, szTagFilter) + let tagItem = {} + for szCurrentContext in a:contextStack + if szCurrentContext != '::' + let szTagQuery = substitute(szCurrentContext, '^::', '', 'g').'::'.a:szSymbol + else + let szTagQuery = a:szSymbol + endif + + let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') + call filter(tagList, a:szTagFilter) + if len(tagList) + let tagItem = tagList[0] + break + endif + endfor + return tagItem +endfunc + +" Return if the tag item represent an unnamed type +function! s:IsUnnamedType(tagItem) + let bResult = 0 + if has_key(a:tagItem, 'typeref') + " Note: Thanks for __anon ! + let bResult = match(a:tagItem.typeref, '\C\<__anon') >= 0 + endif + return bResult +endfunc + +" Search the declaration of a variable and return the type info +function! s:SearchTypeInfoOfDecl(szVariable) + let szReVariable = '\C\<'.a:szVariable.'\>' + + let originalPos = getpos('.') + let origPos = originalPos[1:2] + let curPos = origPos + let stopPos = origPos + + while curPos !=[0,0] + " We go to the start of the current scope + let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) + if curPos != [0,0] + let matchPos = curPos + " Now want to search our variable but we don't want to go in child + " scope + while matchPos != [0,0] + let matchPos = searchpos('{\|'.szReVariable, 'W', stopPos[0]) + if matchPos != [0,0] + " We ignore matches under comment + if omni#cpp#utils#IsCursorInCommentOrString() + continue + endif + + " Getting the current line + let szLine = getline('.') + if match(szLine, szReVariable)>=0 + " We found our variable + " Check if the current instruction is a decl instruction + let tokens = omni#cpp#utils#TokenizeCurrentInstruction() + let szTypeInfo = s:ExtractTypeInfoFromDecl(tokens) + if szTypeInfo != '' + call setpos('.', originalPos) + return omni#cpp#utils#CreateTypeInfo(szTypeInfo) + endif + else + " We found a child scope, we don't want to go in, thus + " we search for the end } of this child scope + let bracketEnd = searchpairpos('{', '', '}', 'nW', g:omni#cpp#utils#expIgnoreComments) + if bracketEnd == [0,0] + break + endif + + if bracketEnd[0] >= stopPos[0] + " The end of the scope is after our cursor we stop + " the search + break + else + " We move the cursor and continue to search our + " variable + call setpos('.', [0, bracketEnd[0], bracketEnd[1], 0]) + endif + endif + endif + endwhile + + " Backing to the start of the scope + call setpos('.', [0,curPos[0], curPos[1], 0]) + let stopPos = curPos + endif + endwhile + + let result = {} + if s:LocalSearchDecl(a:szVariable)==0 && !omni#cpp#utils#IsCursorInCommentOrString() + let tokens = omni#cpp#utils#TokenizeCurrentInstruction() + let szTypeInfo = s:ExtractTypeInfoFromDecl(tokens) + if szTypeInfo != '' + let result = omni#cpp#utils#CreateTypeInfo(szTypeInfo) + endif + endif + + call setpos('.', originalPos) + + return result +endfunc + +" Search a declaration +" @return +" - tokens of the current instruction if success +" - empty list if failure +function! s:SearchDecl(szVariable) + let result = {} + let originalPos = getpos('.') + let searchResult = s:LocalSearchDecl(a:szVariable) + if searchResult==0 + " searchdecl() may detect a decl if the variable is in a conditional + " instruction (if, elseif, while etc...) + " We have to check if the detected decl is really a decl instruction + let tokens = omni#cpp#utils#TokenizeCurrentInstruction() + + for token in tokens + " Simple test + if index(['if', 'elseif', 'while', 'for', 'switch'], token.value)>=0 + " Invalid declaration instruction + call setpos('.', originalPos) + return result + endif + endfor + + let szTypeInfo = s:ExtractTypeInfoFromDecl(tokens) + if szTypeInfo != '' + let result = omni#cpp#utils#CreateTypeInfo(szTypeInfo) + endif + endif + call setpos('.', originalPos) + return result +endfunc + +" Extract the type info string from an instruction. +" We use a small parser to extract the type +" We parse the code according to a C++ BNF from: http://www.nongnu.org/hcb/#basic.link +" @param tokens: token list of the current instruction +function! s:ExtractTypeInfoFromDecl(tokens) + return omni#cpp#utils#ExtractTypeInfoFromTokens(a:tokens) +endfunc + +" Convert tokens to string +function! s:TokensToString(tokens) + let result = '' + for token in a:tokens + let result = result . token.value . ' ' + endfor + return result[:-2] +endfunc + +" Resolve a cast. +" Resolve a C++ cast +" @param list of token. tokens must be a list that represents +" a cast expression (C++ cast) the function does not control +" if it's a cast or not +" eg: static_cast<MyClass*>(something) +" @return type info string +function! s:ResolveCppCast(tokens) + return omni#cpp#utils#ExtractTypeInfoFromTokens(s:ResolveCast(a:tokens, '<', '>')) +endfunc + +" Resolve a cast. +" Resolve a C cast +" @param list of token. tokens must be a list that represents +" a cast expression (C cast) the function does not control +" if it's a cast or not +" eg: (MyClass*)something +" @return type info string +function! s:ResolveCCast(tokens) + return omni#cpp#utils#ExtractTypeInfoFromTokens(s:ResolveCast(a:tokens, '(', ')')) +endfunc + +" Resolve a cast. +" Resolve a C cast +" @param list of token. tokens must be a list that represents +" a cast expression (C cast) the function does not control +" if it's a cast or not +" eg: (MyClass*)something +" @return type tokens +function! s:ResolveCast(tokens, startChar, endChar) + let tokens = omni#cpp#utils#BuildParenthesisGroups(a:tokens) + + " We remove useless parenthesis eg: (((MyClass))) + let tokens = omni#cpp#utils#SimplifyParenthesis(tokens) + + let countItem=0 + let startIndex = -1 + let endIndex = -1 + let i = 0 + for token in tokens + if startIndex==-1 + if token.value==a:startChar + let countItem += 1 + let startIndex = i + endif + else + if token.value==a:startChar + let countItem += 1 + elseif token.value==a:endChar + let countItem -= 1 + endif + + if countItem==0 + let endIndex = i + break + endif + endif + let i+=1 + endfor + + return tokens[startIndex+1 : endIndex-1] +endfunc + +" Replacement for build-in function 'searchdecl' +" It does not require that the upper-level bracket is in the first column. +" Otherwise it should be equal to 'searchdecl(name, 0, 1)' +" @param name: name of variable to find declaration for +function! s:LocalSearchDecl(name) + + if g:OmniCpp_LocalSearchDecl == 0 + let bUserIgnoreCase = &ignorecase + + " Forcing the noignorecase option + " avoid bug when, for example, if we have a declaration like this : "A a;" + set noignorecase + + let result = searchdecl(a:name, 0, 1) + + " Restoring user's setting + let &ignorecase = bUserIgnoreCase + + return result + endif + + let lastpos = getpos('.') + let winview = winsaveview() + let lastfoldenable = &foldenable + let &foldenable = 0 + + " We add \C (noignorecase) to + " avoid bug when, for example, if we have a declaration like this : "A a;" + let varname = "\\C\\<" . a:name . "\\>" + + " Go to first blank line before begin of highest scope + normal 99[{ + let scopepos = getpos('.') + while (line('.') > 1) && (len(split(getline('.'))) > 0) + call cursor(line('.')-1, 0) + endwhile + + let declpos = [ 0, 0, 0, 0 ] + while search(varname, '', scopepos[1]) > 0 + " Check if we are a string or a comment + if omni#cpp#utils#IsCursorInCommentOrString() + continue + endif + + " Remember match + let declpos = getpos('.') + endwhile + if declpos[1] != 0 + " We found a match + call winrestview(winview) + call setpos('.', declpos) + let &foldenable = lastfoldenable + return 0 + endif + + while search(varname, '', lastpos[1]) > 0 + " Check if current scope is ending before variable + let old_cur = getpos('.') + normal ]} + let new_cur = getpos('.') + call setpos('.', old_cur) + if (new_cur[1] < lastpos[1]) || ((new_cur[1] == lastpos[1]) && (new_cur[2] < lastpos[2])) + continue + endif + + " Check if we are a string or a comment + if omni#cpp#utils#IsCursorInCommentOrString() + continue + endif + + " We found match + call winrestview(winview) + call setpos('.', old_cur) + let &foldenable = lastfoldenable + return 0 + endwhile + + " No match found. + call winrestview(winview) + let &foldenable = lastfoldenable + return 1 +endfunc diff --git a/.vim/autoload/omni/cpp/maycomplete.vim b/.vim/autoload/omni/cpp/maycomplete.vim new file mode 100644 index 0000000..610526b --- /dev/null +++ b/.vim/autoload/omni/cpp/maycomplete.vim @@ -0,0 +1,82 @@ +" Description: Omni completion script for cpp files +" Maintainer: Vissale NEANG +" Last Change: 26 sept. 2007 + +" Check if we can use omni completion in the current buffer +function! s:CanUseOmnicompletion() + " For C and C++ files and only if the omnifunc is omni#cpp#complete#Main + return (index(['c', 'cpp'], &filetype)>=0 && &omnifunc == 'omni#cpp#complete#Main' && !omni#cpp#utils#IsCursorInCommentOrString()) +endfunc + +" Return the mapping of omni completion +function! omni#cpp#maycomplete#Complete() + let szOmniMapping = "\<C-X>\<C-O>" + + " 0 = don't select first item + " 1 = select first item (inserting it to the text, default vim behaviour) + " 2 = select first item (without inserting it to the text) + if g:OmniCpp_SelectFirstItem == 0 + " We have to force the menuone option to avoid confusion when there is + " only one popup item + set completeopt-=menu + set completeopt+=menuone + let szOmniMapping .= "\<C-P>" + elseif g:OmniCpp_SelectFirstItem == 2 + " We have to force the menuone option to avoid confusion when there is + " only one popup item + set completeopt-=menu + set completeopt+=menuone + let szOmniMapping .= "\<C-P>" + let szOmniMapping .= "\<C-R>=pumvisible() ? \"\\<down>\" : \"\"\<cr>" + endif + return szOmniMapping +endfunc + +" May complete function for dot +function! omni#cpp#maycomplete#Dot() + if s:CanUseOmnicompletion() && g:OmniCpp_MayCompleteDot + let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction('.')) + if len(g:omni#cpp#items#data) + let s:bMayComplete = 1 + return '.' . omni#cpp#maycomplete#Complete() + endif + endif + return '.' +endfunc +" May complete function for arrow +function! omni#cpp#maycomplete#Arrow() + if s:CanUseOmnicompletion() && g:OmniCpp_MayCompleteArrow + let index = col('.') - 2 + if index >= 0 + let char = getline('.')[index] + if char == '-' + let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction('>')) + if len(g:omni#cpp#items#data) + let s:bMayComplete = 1 + return '>' . omni#cpp#maycomplete#Complete() + endif + endif + endif + endif + return '>' +endfunc + +" May complete function for double points +function! omni#cpp#maycomplete#Scope() + if s:CanUseOmnicompletion() && g:OmniCpp_MayCompleteScope + let index = col('.') - 2 + if index >= 0 + let char = getline('.')[index] + if char == ':' + let g:omni#cpp#items#data = omni#cpp#items#Get(omni#cpp#utils#TokenizeCurrentInstruction(':')) + if len(g:omni#cpp#items#data) + if len(g:omni#cpp#items#data[-1].tokens) && g:omni#cpp#items#data[-1].tokens[-1].value != '::' + let s:bMayComplete = 1 + return ':' . omni#cpp#maycomplete#Complete() + endif + endif + endif + endif + endif + return ':' +endfunc diff --git a/.vim/autoload/omni/cpp/namespaces.vim b/.vim/autoload/omni/cpp/namespaces.vim new file mode 100644 index 0000000..386b3f9 --- /dev/null +++ b/.vim/autoload/omni/cpp/namespaces.vim @@ -0,0 +1,838 @@ +" Description: Omni completion script for cpp files +" Maintainer: Vissale NEANG +" Last Change: 26 sept. 2007 + +let g:omni#cpp#namespaces#CacheResolve = {} +let g:omni#cpp#namespaces#CacheUsing = {} +" TODO: For the next release +"let g:omni#cpp#namespaces#CacheAlias = {} + +" Get the using namespace list from a line +function! s:GetNamespaceAliasListFromLine(szLine) + let result = {} + let tokens = omni#cpp#tokenizer#Tokenize(a:szLine) + let szAlias = '' + let szNamespace = '' + let state = 0 + for token in tokens + if state==0 + let szAlias = '' + let szNamespace = '' + if token.value == '/*' + let state = 1 + elseif token.value == '//' + " It's a comment + let state = -1 + break + elseif token.value == 'namespace' + let state = 2 + endif + elseif state==1 + if token.value == '*/' + let state=0 + endif + elseif state==2 + if token.kind == 'cppWord' + let szAlias .= token.value + let state = 3 + else + let state = -1 + break + endif + elseif state == 3 + if token.value == '=' + let state = 4 + else + let state = -1 + break + endif + elseif state == 4 + if token.value == '::' + let szNamespace .= token.value + let state = 5 + elseif token.kind == 'cppWord' + let szNamespace .= token.value + let state = 6 + " Maybe end of tokens + endif + elseif state==5 + if token.kind == 'cppWord' + let szNamespace .= token.value + let state = 6 + " Maybe end of tokens + else + " Error, we can't have 'namespace ALIAS = Something::' + let state = -1 + break + endif + elseif state==6 + if token.value == '::' + let szNamespace .= token.value + let state = 5 + else + call extend(result, {szAlias : szNamespace}) + let state = 0 + endif + endif + endfor + + if state == 6 + call extend(result, {szAlias : szNamespace}) + endif + + return result +endfunc + +" Get the using namespace list from a line +function! s:GetNamespaceListFromLine(szLine) + let result = [] + let tokens = omni#cpp#tokenizer#Tokenize(a:szLine) + let szNamespace = '' + let state = 0 + for token in tokens + if state==0 + let szNamespace = '' + if token.value == '/*' + let state = 1 + elseif token.value == '//' + " It's a comment + let state = -1 + break + elseif token.value == 'using' + let state = 2 + endif + elseif state==1 + if token.value == '*/' + let state=0 + endif + elseif state==2 + if token.value == 'namespace' + let state = 3 + else + " Error, 'using' must be followed by 'namespace' + let state = -1 + break + endif + elseif state==3 + if token.value == '::' + let szNamespace .= token.value + let state = 4 + elseif token.kind == 'cppWord' + let szNamespace .= token.value + let state = 5 + " Maybe end of tokens + endif + elseif state==4 + if token.kind == 'cppWord' + let szNamespace .= token.value + let state = 5 + " Maybe end of tokens + else + " Error, we can't have 'using namespace Something::' + let state = -1 + break + endif + elseif state==5 + if token.value == '::' + let szNamespace .= token.value + let state = 4 + else + call extend(result, [szNamespace]) + let state = 0 + endif + endif + endfor + + if state == 5 + call extend(result, [szNamespace]) + endif + + return result +endfunc + +" Get the namespace list from a namespace map +function! s:GetUsingNamespaceListFromMap(namespaceMap, ...) + let stopLine = 0 + if a:0>0 + let stopLine = a:1 + endif + + let result = [] + let keys = sort(keys(a:namespaceMap), 'omni#common#utils#CompareNumber') + for i in keys + if stopLine != 0 && i > stopLine + break + endif + call extend(result, a:namespaceMap[i]) + endfor + return result +endfunc + +" Get global using namespace list from the current buffer +function! omni#cpp#namespaces#GetListFromCurrentBuffer(...) + let namespaceMap = s:GetAllUsingNamespaceMapFromCurrentBuffer() + let result = [] + if namespaceMap != {} + let result = s:GetUsingNamespaceListFromMap(namespaceMap, (a:0 > 0)? a:1 : line('.')) + endif + return result +endfunc + +" Get global using namespace map from the current buffer and include files recursively +function! s:GetAllUsingNamespaceMapFromCurrentBuffer(...) + let includeGuard = (a:0>0)? a:1 : {} + + let szBufferName = getreg("%") + let szFilePath = omni#cpp#utils#ResolveFilePath(szBufferName) + let szFilePath = (szFilePath=='')? szBufferName : szFilePath + + let namespaceMap = {} + if has_key(includeGuard, szFilePath) + return namespaceMap + else + let includeGuard[szFilePath] = 1 + endif + + let namespaceMap = omni#cpp#namespaces#GetMapFromCurrentBuffer() + + if g:OmniCpp_NamespaceSearch != 2 + " We don't search included files if OmniCpp_NamespaceSearch != 2 + return namespaceMap + endif + + for inc in omni#cpp#includes#GetList() + let lnum = inc.pos[0] + let tmpMap = s:GetAllUsingNamespaceMapFromFile(inc.include, includeGuard) + if tmpMap != {} + if has_key(namespaceMap, lnum) + call extend(namespaceMap[lnum], s:GetUsingNamespaceListFromMap(tmpMap)) + else + let namespaceMap[lnum] = s:GetUsingNamespaceListFromMap(tmpMap) + endif + endif + endfor + + return namespaceMap +endfunc + +" Get global using namespace map from a file and include files recursively +function! s:GetAllUsingNamespaceMapFromFile(szFilePath, ...) + let includeGuard = {} + if a:0 >0 + let includeGuard = a:1 + endif + + let szFilePath = omni#cpp#utils#ResolveFilePath(a:szFilePath) + let szFilePath = (szFilePath=='')? a:szFilePath : szFilePath + + let namespaceMap = {} + if has_key(includeGuard, szFilePath) + return namespaceMap + else + let includeGuard[szFilePath] = 1 + endif + + " If g:OmniCpp_NamespaceSearch == 1 (search namespaces only in the current + " buffer) we don't use cache for the current buffer + let namespaceMap = omni#cpp#namespaces#GetMapFromBuffer(szFilePath, g:OmniCpp_NamespaceSearch==1) + + if g:OmniCpp_NamespaceSearch != 2 + " We don't search included files if OmniCpp_NamespaceSearch != 2 + return namespaceMap + endif + + for inc in omni#cpp#includes#GetList(szFilePath) + let lnum = inc.pos[0] + let tmpMap = s:GetAllUsingNamespaceMapFromFile(inc.include, includeGuard) + if tmpMap != {} + if has_key(namespaceMap, lnum) + call extend(namespaceMap[lnum], s:GetUsingNamespaceListFromMap(tmpMap)) + else + let namespaceMap[lnum] = s:GetUsingNamespaceListFromMap(tmpMap) + endif + endif + endfor + + return namespaceMap +endfunc + +" Get global using namespace map from a the current buffer +function! omni#cpp#namespaces#GetMapFromCurrentBuffer() + let namespaceMap = {} + let originalPos = getpos('.') + + call setpos('.', [0, 1, 1, 0]) + let curPos = [1,1] + while curPos != [0,0] + let curPos = searchpos('\C^using\s\+namespace', 'W') + if curPos != [0,0] + let szLine = getline('.') + let startPos = curPos[1] + let endPos = match(szLine, ';', startPos-1) + if endPos!=-1 + " We get the namespace list from the line + let namespaceMap[curPos[0]] = s:GetNamespaceListFromLine(szLine) + endif + endif + endwhile + + call setpos('.', originalPos) + return namespaceMap +endfunc + +" Get global using namespace map from a file +function! omni#cpp#namespaces#GetMapFromBuffer(szFilePath, ...) + let bUpdate = 0 + if a:0 > 0 + let bUpdate = a:1 + endif + + let szFilePath = omni#cpp#utils#ResolveFilePath(a:szFilePath) + let szFilePath = (szFilePath=='')? a:szFilePath : szFilePath + + if !bUpdate && has_key(g:omni#cpp#namespaces#CacheUsing, szFilePath) + return copy(g:omni#cpp#namespaces#CacheUsing[szFilePath]) + endif + + let namespaceMap = {} + " The file exists, we get the global namespaces in this file + let szFixedPath = escape(szFilePath, g:omni#cpp#utils#szEscapedCharacters) + execute 'silent! lvimgrep /\C^using\s\+namespace/gj '.szFixedPath + + " key = line number + " value = list of namespaces + let listQuickFix = getloclist(0) + for qf in listQuickFix + let szLine = qf.text + let startPos = qf.col + let endPos = match(szLine, ';', startPos-1) + if endPos!=-1 + " We get the namespace list from the line + let namespaceMap[qf.lnum] = s:GetNamespaceListFromLine(szLine) + endif + endfor + + if szFixedPath != '' + let g:omni#cpp#namespaces#CacheUsing[szFixedPath] = namespaceMap + endif + + return copy(namespaceMap) +endfunc + +" Get the stop position when searching for local variables +function! s:GetStopPositionForLocalSearch() + " Stop position when searching a local variable + let originalPos = getpos('.') + let origPos = originalPos[1:2] + let stopPosition = origPos + let curPos = origPos + while curPos !=[0,0] + let stopPosition = curPos + let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) + endwhile + call setpos('.', originalPos) + + return stopPosition +endfunc + +" Get namespaces alias used at the cursor postion in a vim buffer +" Note: The result depends on the current cursor position +" @return +" - Map of namespace alias +function! s:GetNamespaceAliasMap() + " We store the cursor position because searchpairpos() moves the cursor + let result = {} + let originalPos = getpos('.') + let origPos = originalPos[1:2] + + let stopPos = s:GetStopPositionForLocalSearch() + let stopLine = stopPos[0] + let curPos = origPos + let lastLine = 0 + let nextStopLine = origPos[0] + let szReAlias = '\Cnamespace\s\+\w\+\s\+=' + while curPos !=[0,0] + let curPos = searchpos('}\|\('. szReAlias .'\)', 'bW',stopLine) + if curPos!=[0,0] && curPos[0]!=lastLine + let lastLine = curPos[0] + + let szLine = getline('.') + if origPos[0] == curPos[0] + " We get the line until cursor position + let szLine = szLine[:origPos[1]] + endif + + let szLine = omni#cpp#utils#GetCodeFromLine(szLine) + if match(szLine, szReAlias)<0 + " We found a '}' + let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) + else + " We get the namespace alias from the line + call extend(result, s:GetNamespaceAliasListFromLine(szLine)) + let nextStopLine = curPos[0] + endif + endif + endwhile + + " Setting the cursor to the original position + call setpos('.', originalPos) + + call s:ResolveAliasKeys(result) + return result +endfunc + +" Resolve an alias +" eg: namespace IAmAnAlias1 = Ns1 +" eg: namespace IAmAnAlias2 = IAmAnAlias1::Ns2 +" => IAmAnAlias2 = Ns1::Ns2 +function! s:ResolveAliasKey(mapNamespaceAlias, szAlias) + let szResult = a:mapNamespaceAlias[a:szAlias] + " ::Ns1::Ns2::Ns3 => ['Ns1', 'Ns2', 'Ns3'] + let listNamespace = split(szResult, '::') + if len(listNamespace) + " szBeginPart = 'Ns1' + let szBeginPart = remove(listNamespace, 0) + + " Is 'Ns1' an alias ? + if has_key(a:mapNamespaceAlias, szBeginPart) && szBeginPart != a:szAlias + " Resolving alias 'Ns1' + " eg: Ns1 = NsResolved + let szResult = s:ResolveAliasKey(a:mapNamespaceAlias, szBeginPart) + " szEndPart = 'Ns2::Ns3' + let szEndPart = join(listNamespace, '::') + if szEndPart != '' + " Concatenation => szResult = 'NsResolved::Ns2::Ns3' + let szResult .= '::' . szEndPart + endif + endif + endif + return szResult +endfunc + +" Resolve all keys in the namespace alias map +function! s:ResolveAliasKeys(mapNamespaceAlias) + let mapNamespaceAlias = a:mapNamespaceAlias + call map(mapNamespaceAlias, 's:ResolveAliasKey(mapNamespaceAlias, v:key)') +endfunc + +" Resolve namespace alias +function! omni#cpp#namespaces#ResolveAlias(mapNamespaceAlias, szNamespace) + let szResult = a:szNamespace + " ::Ns1::Ns2::Ns3 => ['Ns1', 'Ns2', 'Ns3'] + let listNamespace = split(a:szNamespace, '::') + if len(listNamespace) + " szBeginPart = 'Ns1' + let szBeginPart = remove(listNamespace, 0) + + " Is 'Ns1' an alias ? + if has_key(a:mapNamespaceAlias, szBeginPart) + " Resolving alias 'Ns1' + " eg: Ns1 = NsResolved + let szResult = a:mapNamespaceAlias[szBeginPart] + " szEndPart = 'Ns2::Ns3' + let szEndPart = join(listNamespace, '::') + if szEndPart != '' + " Concatenation => szResult = 'NsResolved::Ns2::Ns3' + let szResult .= '::' . szEndPart + endif + + " If a:szNamespace starts with '::' we add '::' to the beginning + " of the result + if match(a:szNamespace, '^::')>=0 + let szResult = omni#cpp#utils#SimplifyScope('::' . szResult) + endif + endif + endif + return szResult +endfunc + +" Resolve namespace alias +function! s:ResolveAliasInNamespaceList(mapNamespaceAlias, listNamespaces) + call map(a:listNamespaces, 'omni#cpp#namespaces#ResolveAlias(a:mapNamespaceAlias, v:val)') +endfunc + +" Get namespaces used at the cursor postion in a vim buffer +" Note: The result depends on the current cursor position +" @return +" - List of namespace used in the reverse order +function! omni#cpp#namespaces#GetUsingNamespaces() + " We have to get local using namespace declarations + " We need the current cursor position and the position of the start of the + " current scope + + " We store the cursor position because searchpairpos() moves the cursor + let result = [] + let originalPos = getpos('.') + let origPos = originalPos[1:2] + + let stopPos = s:GetStopPositionForLocalSearch() + + let stopLine = stopPos[0] + let curPos = origPos + let lastLine = 0 + let nextStopLine = origPos[0] + while curPos !=[0,0] + let curPos = searchpos('\C}\|\(using\s\+namespace\)', 'bW',stopLine) + if curPos!=[0,0] && curPos[0]!=lastLine + let lastLine = curPos[0] + + let szLine = getline('.') + if origPos[0] == curPos[0] + " We get the line until cursor position + let szLine = szLine[:origPos[1]] + endif + + let szLine = omni#cpp#utils#GetCodeFromLine(szLine) + if match(szLine, '\Cusing\s\+namespace')<0 + " We found a '}' + let curPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) + else + " We get the namespace list from the line + let result = s:GetNamespaceListFromLine(szLine) + result + let nextStopLine = curPos[0] + endif + endif + endwhile + + " Setting the cursor to the original position + call setpos('.', originalPos) + + " 2) Now we can get all global using namespace declaration from the + " beginning of the file to nextStopLine + let result = omni#cpp#namespaces#GetListFromCurrentBuffer(nextStopLine) + result + + " Resolving alias in the namespace list + " TODO: For the next release + "let g:omni#cpp#namespaces#CacheAlias= s:GetNamespaceAliasMap() + "call s:ResolveAliasInNamespaceList(g:omni#cpp#namespaces#CacheAlias, result) + + return ['::'] + result +endfunc + +" Resolve a using namespace regarding the current context +" For each namespace used: +" - We get all possible contexts where the namespace +" can be define +" - We do a comparison test of each parent contexts with the current +" context list +" - If one and only one parent context is present in the +" current context list we add the namespace in the current +" context +" - If there is more than one of parent contexts in the +" current context the namespace is ambiguous +" @return +" - result item +" - kind = 0|1 +" - 0 = unresolved or error +" - 1 = resolved +" - value = resolved namespace +function! s:ResolveNamespace(namespace, mapCurrentContexts) + let result = {'kind':0, 'value': ''} + + " If the namespace is already resolved we add it in the list of + " current contexts + if match(a:namespace, '^::')>=0 + let result.kind = 1 + let result.value = a:namespace + return result + elseif match(a:namespace, '\w\+::\w\+')>=0 + let mapCurrentContextsTmp = copy(a:mapCurrentContexts) + let resolvedItem = {} + for nsTmp in split(a:namespace, '::') + let resolvedItem = s:ResolveNamespace(nsTmp, mapCurrentContextsTmp) + if resolvedItem.kind + " Note: We don't extend the map + let mapCurrentContextsTmp = {resolvedItem.value : 1} + else + break + endif + endfor + if resolvedItem!={} && resolvedItem.kind + let result.kind = 1 + let result.value = resolvedItem.value + endif + return result + endif + + " We get all possible parent contexts of this namespace + let listTagsOfNamespace = [] + if has_key(g:omni#cpp#namespaces#CacheResolve, a:namespace) + let listTagsOfNamespace = g:omni#cpp#namespaces#CacheResolve[a:namespace] + else + let listTagsOfNamespace = omni#common#utils#TagList('^'.a:namespace.'$') + let g:omni#cpp#namespaces#CacheResolve[a:namespace] = listTagsOfNamespace + endif + + if len(listTagsOfNamespace)==0 + return result + endif + call filter(listTagsOfNamespace, 'v:val.kind[0]=="n"') + + " We extract parent context from tags + " We use a map to avoid multiple entries + let mapContext = {} + for tagItem in listTagsOfNamespace + let szParentContext = omni#cpp#utils#ExtractScope(tagItem) + let mapContext[szParentContext] = 1 + endfor + let listParentContext = keys(mapContext) + + " Now for each parent context we test if the context is in the current + " contexts list + let listResolvedNamespace = [] + for szParentContext in listParentContext + if has_key(a:mapCurrentContexts, szParentContext) + call extend(listResolvedNamespace, [omni#cpp#utils#SimplifyScope(szParentContext.'::'.a:namespace)]) + endif + endfor + + " Now we know if the namespace is ambiguous or not + let len = len(listResolvedNamespace) + if len==1 + " Namespace resolved + let result.kind = 1 + let result.value = listResolvedNamespace[0] + elseif len > 1 + " Ambiguous namespace, possible matches are in listResolvedNamespace + else + " Other cases + endif + return result +endfunc + +" Resolve namespaces +"@return +" - List of resolved namespaces +function! omni#cpp#namespaces#ResolveAll(namespacesUsed) + + " We add the default context '::' + let contextOrder = 0 + let mapCurrentContexts = {} + + " For each namespace used: + " - We get all possible contexts where the namespace + " can be define + " - We do a comparison test of each parent contexts with the current + " context list + " - If one and only one parent context is present in the + " current context list we add the namespace in the current + " context + " - If there is more than one of parent contexts in the + " current context the namespace is ambiguous + for ns in a:namespacesUsed + let resolvedItem = s:ResolveNamespace(ns, mapCurrentContexts) + if resolvedItem.kind + let contextOrder+=1 + let mapCurrentContexts[resolvedItem.value] = contextOrder + endif + endfor + + " Build the list of current contexts from the map, we have to keep the + " order + let mapReorder = {} + for key in keys(mapCurrentContexts) + let mapReorder[ mapCurrentContexts[key] ] = key + endfor + let result = [] + for key in sort(keys(mapReorder)) + call extend(result, [mapReorder[key]]) + endfor + return result +endfunc + +" Build the context stack +function! s:BuildContextStack(namespaces, szCurrentScope) + let result = copy(a:namespaces) + if a:szCurrentScope != '::' + let tagItem = omni#cpp#utils#GetResolvedTagItem(a:namespaces, omni#cpp#utils#CreateTypeInfo(a:szCurrentScope)) + if has_key(tagItem, 'inherits') + let listBaseClass = omni#cpp#utils#GetClassInheritanceList(a:namespaces, omni#cpp#utils#CreateTypeInfo(a:szCurrentScope)) + let result = listBaseClass + result + elseif has_key(tagItem, 'kind') && index(['c', 's', 'u', 'n'], tagItem.kind[0])>=0 + call insert(result, omni#cpp#utils#ExtractTypeInfoFromTag(tagItem)) + endif + endif + return result +endfunc + +" Returns the class scope at the current position of the cursor +" @return a string that represents the class scope +" eg: ::NameSpace1::Class1 +" The returned string always starts with '::' +" Note: In term of performance it's the weak point of the script +function! s:GetClassScopeAtCursor() + " We store the cursor position because searchpairpos() moves the cursor + let originalPos = getpos('.') + let endPos = originalPos[1:2] + let listCode = [] + let result = {'namespaces': [], 'scope': ''} + + while endPos!=[0,0] + let endPos = searchpairpos('{', '', '}', 'bW', g:omni#cpp#utils#expIgnoreComments) + let szReStartPos = '[;{}]\|\%^' + let startPos = searchpairpos(szReStartPos, '', '{', 'bWn', g:omni#cpp#utils#expIgnoreComments) + + " If the file starts with a comment so the startPos can be [0,0] + " we change it to [1,1] + if startPos==[0,0] + let startPos = [1,1] + endif + + " Get lines backward from cursor position to last ; or { or } + " or when we are at the beginning of the file. + " We store lines in listCode + if endPos!=[0,0] + " We remove the last character which is a '{' + " We also remove starting { or } or ; if exits + let szCodeWithoutComments = substitute(omni#cpp#utils#GetCode(startPos, endPos)[:-2], '^[;{}]', '', 'g') + call insert(listCode, {'startLine' : startPos[0], 'code' : szCodeWithoutComments}) + endif + endwhile + " Setting the cursor to the original position + call setpos('.', originalPos) + + let listClassScope = [] + let bResolved = 0 + let startLine = 0 + " Now we can check in the list of code if there is a function + for code in listCode + " We get the name of the namespace, class, struct or union + " and we store it in listClassScope + let tokens = omni#cpp#tokenizer#Tokenize(code.code) + let bContinue=0 + let bAddNamespace = 0 + let state=0 + for token in tokens + if state==0 + if index(['namespace', 'class', 'struct', 'union'], token.value)>=0 + if token.value == 'namespace' + let bAddNamespace = 1 + endif + let state= 1 + " Maybe end of tokens + endif + elseif state==1 + if token.kind == 'cppWord' + " eg: namespace MyNs { class MyCl {}; } + " => listClassScope = [MyNs, MyCl] + call extend( listClassScope , [token.value] ) + + " Add the namespace in result + if bAddNamespace + call extend(result.namespaces, [token.value]) + let bAddNamespace = 0 + endif + + let bContinue=1 + break + endif + endif + endfor + if bContinue==1 + continue + endif + + " Simple test to check if we have a chance to find a + " class method + let aPos = matchend(code.code, '::\s*\~*\s*\w\+\s*(') + if aPos ==-1 + continue + endif + + let startLine = code.startLine + let listTmp = [] + " eg: 'void MyNamespace::MyClass::foo(' + " => tokens = ['MyClass', '::', 'MyNamespace', 'void'] + let tokens = reverse(omni#cpp#tokenizer#Tokenize(code.code[:aPos-1])[:-4]) + let state = 0 + " Reading tokens backward + for token in tokens + if state==0 + if token.kind=='cppWord' + call insert(listTmp, token.value) + let state=1 + endif + elseif state==1 + if token.value=='::' + let state=2 + else + break + endif + elseif state==2 + if token.kind=='cppWord' + call insert(listTmp, token.value) + let state=1 + else + break + endif + endif + endfor + + if len(listTmp) + if len(listClassScope) + let bResolved = 1 + " Merging class scopes + " eg: current class scope = 'MyNs::MyCl1' + " method class scope = 'MyCl1::MyCl2' + " If we add the method class scope to current class scope + " we'll have MyNs::MyCl1::MyCl1::MyCl2 => it's wrong + " we want MyNs::MyCl1::MyCl2 + let index = 0 + for methodClassScope in listTmp + if methodClassScope==listClassScope[-1] + let listTmp = listTmp[index+1:] + break + else + let index+=1 + endif + endfor + endif + call extend(listClassScope, listTmp) + break + endif + endfor + + let szClassScope = '::' + if len(listClassScope) + if bResolved + let szClassScope .= join(listClassScope, '::') + else + let szClassScope = join(listClassScope, '::') + + " The class scope is not resolved, we have to check using + " namespace declarations and search the class scope in each + " namespace + if startLine != 0 + let namespaces = ['::'] + omni#cpp#namespaces#GetListFromCurrentBuffer(startLine) + let namespaces = omni#cpp#namespaces#ResolveAll(namespaces) + let tagItem = omni#cpp#utils#GetResolvedTagItem(namespaces, omni#cpp#utils#CreateTypeInfo(szClassScope)) + if tagItem != {} + let szClassScope = omni#cpp#utils#ExtractTypeInfoFromTag(tagItem) + endif + endif + endif + endif + + let result.scope = szClassScope + return result +endfunc + +" Get all contexts at the cursor position +function! omni#cpp#namespaces#GetContexts() + " Get the current class scope at the cursor, the result depends on the current cursor position + let scopeItem = s:GetClassScopeAtCursor() + let listUsingNamespace = copy(g:OmniCpp_DefaultNamespaces) + call extend(listUsingNamespace, scopeItem.namespaces) + if g:OmniCpp_NamespaceSearch && &filetype != 'c' + " Get namespaces used in the file until the cursor position + let listUsingNamespace = omni#cpp#namespaces#GetUsingNamespaces() + listUsingNamespace + " Resolving namespaces, removing ambiguous namespaces + let namespaces = omni#cpp#namespaces#ResolveAll(listUsingNamespace) + else + let namespaces = ['::'] + listUsingNamespace + endif + call reverse(namespaces) + + " Building context stack from namespaces and the current class scope + return s:BuildContextStack(namespaces, scopeItem.scope) +endfunc diff --git a/.vim/autoload/omni/cpp/settings.vim b/.vim/autoload/omni/cpp/settings.vim new file mode 100644 index 0000000..6683d3a --- /dev/null +++ b/.vim/autoload/omni/cpp/settings.vim @@ -0,0 +1,96 @@ +" Description: Omni completion script for cpp files +" Maintainer: Vissale NEANG +" Last Change: 26 sept. 2007 + +function! omni#cpp#settings#Init() + " Global scope search on/off + " 0 = disabled + " 1 = enabled + if !exists('g:OmniCpp_GlobalScopeSearch') + let g:OmniCpp_GlobalScopeSearch = 1 + endif + + " Sets the namespace search method + " 0 = disabled + " 1 = search namespaces in the current file + " 2 = search namespaces in the current file and included files + if !exists('g:OmniCpp_NamespaceSearch') + let g:OmniCpp_NamespaceSearch = 1 + endif + + " Set the class scope completion mode + " 0 = auto + " 1 = show all members (static, public, protected and private) + if !exists('g:OmniCpp_DisplayMode') + let g:OmniCpp_DisplayMode = 0 + endif + + " Set if the scope is displayed in the abbr column of the popup + " 0 = no + " 1 = yes + if !exists('g:OmniCpp_ShowScopeInAbbr') + let g:OmniCpp_ShowScopeInAbbr = 0 + endif + + " Set if the function prototype is displayed in the abbr column of the popup + " 0 = no + " 1 = yes + if !exists('g:OmniCpp_ShowPrototypeInAbbr') + let g:OmniCpp_ShowPrototypeInAbbr = 0 + endif + + " Set if the access (+,#,-) is displayed + " 0 = no + " 1 = yes + if !exists('g:OmniCpp_ShowAccess') + let g:OmniCpp_ShowAccess = 1 + endif + + " Set the list of default namespaces + " eg: ['std'] + if !exists('g:OmniCpp_DefaultNamespaces') + let g:OmniCpp_DefaultNamespaces = [] + endif + + " Set MayComplete to '.' + " 0 = disabled + " 1 = enabled + " default = 1 + if !exists('g:OmniCpp_MayCompleteDot') + let g:OmniCpp_MayCompleteDot = 1 + endif + + " Set MayComplete to '->' + " 0 = disabled + " 1 = enabled + " default = 1 + if !exists('g:OmniCpp_MayCompleteArrow') + let g:OmniCpp_MayCompleteArrow = 1 + endif + + " Set MayComplete to dot + " 0 = disabled + " 1 = enabled + " default = 0 + if !exists('g:OmniCpp_MayCompleteScope') + let g:OmniCpp_MayCompleteScope = 0 + endif + + " When completeopt does not contain longest option, this setting + " controls the behaviour of the popup menu selection when starting the completion + " 0 = don't select first item + " 1 = select first item (inserting it to the text) + " 2 = select first item (without inserting it to the text) + " default = 0 + if !exists('g:OmniCpp_SelectFirstItem') + let g:OmniCpp_SelectFirstItem= 0 + endif + + " Use local search function for variable definitions + " 0 = use standard vim search function + " 1 = use local search function + " default = 0 + if !exists('g:OmniCpp_LocalSearchDecl') + let g:OmniCpp_LocalSearchDecl= 0 + endif +endfunc diff --git a/.vim/autoload/omni/cpp/tokenizer.vim b/.vim/autoload/omni/cpp/tokenizer.vim new file mode 100644 index 0000000..16e0be2 --- /dev/null +++ b/.vim/autoload/omni/cpp/tokenizer.vim @@ -0,0 +1,93 @@ +" Description: Omni completion tokenizer +" Maintainer: Vissale NEANG +" Last Change: 26 sept. 2007 +" TODO: Generic behaviour for Tokenize() + +" From the C++ BNF +let s:cppKeyword = ['asm', 'auto', 'bool', 'break', 'case', 'catch', 'char', 'class', 'const', 'const_cast', 'continue', 'default', 'delete', 'do', 'double', 'dynamic_cast', 'else', 'enum', 'explicit', 'export', 'extern', 'false', 'float', 'for', 'friend', 'goto', 'if', 'inline', 'int', 'long', 'mutable', 'namespace', 'new', 'operator', 'private', 'protected', 'public', 'register', 'reinterpret_cast', 'return', 'short', 'signed', 'sizeof', 'static', 'static_cast', 'struct', 'switch', 'template', 'this', 'throw', 'true', 'try', 'typedef', 'typeid', 'typename', 'union', 'unsigned', 'using', 'virtual', 'void', 'volatile', 'wchar_t', 'while', 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not', 'not_eq', 'or', 'or_eq', 'xor', 'xor_eq'] + +let s:reCppKeyword = '\C\<'.join(s:cppKeyword, '\>\|\<').'\>' + +" The order of items in this list is very important because we use this list to build a regular +" expression (see below) for tokenization +let s:cppOperatorPunctuator = ['->*', '->', '--', '-=', '-', '!=', '!', '##', '#', '%:%:', '%=', '%>', '%:', '%', '&&', '&=', '&', '(', ')', '*=', '*', ',', '...', '.*', '.', '/=', '/', '::', ':>', ':', ';', '?', '[', ']', '^=', '^', '{', '||', '|=', '|', '}', '~', '++', '+=', '+', '<<=', '<%', '<:', '<<', '<=', '<', '==', '=', '>>=', '>>', '>=', '>'] + +" We build the regexp for the tokenizer +let s:reCComment = '\/\*\|\*\/' +let s:reCppComment = '\/\/' +let s:reComment = s:reCComment.'\|'.s:reCppComment +let s:reCppOperatorOrPunctuator = escape(join(s:cppOperatorPunctuator, '\|'), '*./^~[]') + + +" Tokenize a c++ code +" a token is dictionary where keys are: +" - kind = cppKeyword|cppWord|cppOperatorPunctuator|unknown|cComment|cppComment|cppDigit +" - value = 'something' +" Note: a cppWord is any word that is not a cpp keyword +function! omni#cpp#tokenizer#Tokenize(szCode) + let result = [] + + " The regexp to find a token, a token is a keyword, word or + " c++ operator or punctuator. To work properly we have to put + " spaces and tabs to our regexp. + let reTokenSearch = '\(\w\+\)\|\s\+\|'.s:reComment.'\|'.s:reCppOperatorOrPunctuator + " eg: 'using namespace std;' + " ^ ^ + " start=0 end=5 + let startPos = 0 + let endPos = matchend(a:szCode, reTokenSearch) + let len = endPos-startPos + while endPos!=-1 + " eg: 'using namespace std;' + " ^ ^ + " start=0 end=5 + " token = 'using' + " We also remove space and tabs + let token = substitute(strpart(a:szCode, startPos, len), '\s', '', 'g') + + " eg: 'using namespace std;' + " ^ ^ + " start=5 end=15 + let startPos = endPos + let endPos = matchend(a:szCode, reTokenSearch, startPos) + let len = endPos-startPos + + " It the token is empty we continue + if token=='' + continue + endif + + " Building the token + let resultToken = {'kind' : 'unknown', 'value' : token} + + " Classify the token + if token =~ '^\d\+' + " It's a digit + let resultToken.kind = 'cppDigit' + elseif token=~'^\w\+$' + " It's a word + let resultToken.kind = 'cppWord' + + " But maybe it's a c++ keyword + if match(token, s:reCppKeyword)>=0 + let resultToken.kind = 'cppKeyword' + endif + else + if match(token, s:reComment)>=0 + if index(['/*','*/'],token)>=0 + let resultToken.kind = 'cComment' + else + let resultToken.kind = 'cppComment' + endif + else + " It's an operator + let resultToken.kind = 'cppOperatorPunctuator' + endif + endif + + " We have our token, let's add it to the result list + call extend(result, [resultToken]) + endwhile + + return result +endfunc diff --git a/.vim/autoload/omni/cpp/utils.vim b/.vim/autoload/omni/cpp/utils.vim new file mode 100644 index 0000000..5d74d34 --- /dev/null +++ b/.vim/autoload/omni/cpp/utils.vim @@ -0,0 +1,587 @@ +" Description: Omni completion script for cpp files +" Maintainer: Vissale NEANG +" Last Change: 26 sept. 2007 + +let g:omni#cpp#utils#CACHE_TAG_INHERITS = {} +let g:omni#cpp#utils#szFilterGlobalScope = "(!has_key(v:val, 'class') && !has_key(v:val, 'struct') && !has_key(v:val, 'union') && !has_key(v:val, 'namespace')" +let g:omni#cpp#utils#szFilterGlobalScope .= "&& (!has_key(v:val, 'enum') || (has_key(v:val, 'enum') && v:val.enum =~ '^\\w\\+$')))" + +" Expression used to ignore comments +" Note: this expression drop drastically the performance +"let omni#cpp#utils#expIgnoreComments = 'match(synIDattr(synID(line("."), col("."), 1), "name"), '\CcComment')!=-1' +" This one is faster but not really good for C comments +let omni#cpp#utils#reIgnoreComment = escape('\/\/\|\/\*\|\*\/', '*/\') +let omni#cpp#utils#expIgnoreComments = 'getline(".") =~ g:omni#cpp#utils#reIgnoreComment' + +" Characters to escape in a filename for vimgrep +"TODO: Find more characters to escape +let omni#cpp#utils#szEscapedCharacters = ' %#' + +" Resolve the path of the file +" TODO: absolute file path +function! omni#cpp#utils#ResolveFilePath(szFile) + let result = '' + let listPath = split(globpath(&path, a:szFile), "\n") + if len(listPath) + let result = listPath[0] + endif + return simplify(result) +endfunc + +" Get code without comments and with empty strings +" szSingleLine must not have carriage return +function! omni#cpp#utils#GetCodeFromLine(szSingleLine) + " We set all strings to empty strings, it's safer for + " the next of the process + let szResult = substitute(a:szSingleLine, '".*"', '""', 'g') + + " Removing c++ comments, we can use the pattern ".*" because + " we are modifying a line + let szResult = substitute(szResult, '\/\/.*', '', 'g') + + " Now we have the entire code in one line and we can remove C comments + return s:RemoveCComments(szResult) +endfunc + +" Remove C comments on a line +function! s:RemoveCComments(szLine) + let result = a:szLine + + " We have to match the first '/*' and first '*/' + let startCmt = match(result, '\/\*') + let endCmt = match(result, '\*\/') + while startCmt!=-1 && endCmt!=-1 && startCmt<endCmt + if startCmt>0 + let result = result[ : startCmt-1 ] . result[ endCmt+2 : ] + else + " Case where '/*' is at the start of the line + let result = result[ endCmt+2 : ] + endif + let startCmt = match(result, '\/\*') + let endCmt = match(result, '\*\/') + endwhile + return result +endfunc + +" Get a c++ code from current buffer from [lineStart, colStart] to +" [lineEnd, colEnd] without c++ and c comments, without end of line +" and with empty strings if any +" @return a string +function! omni#cpp#utils#GetCode(posStart, posEnd) + let posStart = a:posStart + let posEnd = a:posEnd + if a:posStart[0]>a:posEnd[0] + let posStart = a:posEnd + let posEnd = a:posStart + elseif a:posStart[0]==a:posEnd[0] && a:posStart[1]>a:posEnd[1] + let posStart = a:posEnd + let posEnd = a:posStart + endif + + " Getting the lines + let lines = getline(posStart[0], posEnd[0]) + let lenLines = len(lines) + + " Formatting the result + let result = '' + if lenLines==1 + let sStart = posStart[1]-1 + let sEnd = posEnd[1]-1 + let line = lines[0] + let lenLastLine = strlen(line) + let sEnd = (sEnd>lenLastLine)?lenLastLine : sEnd + if sStart >= 0 + let result = omni#cpp#utils#GetCodeFromLine(line[ sStart : sEnd ]) + endif + elseif lenLines>1 + let sStart = posStart[1]-1 + let sEnd = posEnd[1]-1 + let lenLastLine = strlen(lines[-1]) + let sEnd = (sEnd>lenLastLine)?lenLastLine : sEnd + if sStart >= 0 + let lines[0] = lines[0][ sStart : ] + let lines[-1] = lines[-1][ : sEnd ] + for aLine in lines + let result = result . omni#cpp#utils#GetCodeFromLine(aLine)." " + endfor + let result = result[:-2] + endif + endif + + " Now we have the entire code in one line and we can remove C comments + return s:RemoveCComments(result) +endfunc + +" Extract the scope (context) of a tag item +" eg: ::MyNamespace +" @return a string of the scope. a scope from tag always starts with '::' +function! omni#cpp#utils#ExtractScope(tagItem) + let listKindScope = ['class', 'struct', 'union', 'namespace', 'enum'] + let szResult = '::' + for scope in listKindScope + if has_key(a:tagItem, scope) + let szResult = szResult . a:tagItem[scope] + break + endif + endfor + return szResult +endfunc + +" Simplify scope string, remove consecutive '::' if any +function! omni#cpp#utils#SimplifyScope(szScope) + let szResult = substitute(a:szScope, '\(::\)\+', '::', 'g') + if szResult=='::' + return szResult + else + return substitute(szResult, '::$', '', 'g') + endif +endfunc + +" Check if the cursor is in comment +function! omni#cpp#utils#IsCursorInCommentOrString() + return match(synIDattr(synID(line("."), col(".")-1, 1), "name"), '\C\<cComment\|\<cCppString\|\<cIncluded')>=0 +endfunc + +" Tokenize the current instruction until the cursor position. +" @return list of tokens +function! omni#cpp#utils#TokenizeCurrentInstruction(...) + let szAppendText = '' + if a:0>0 + let szAppendText = a:1 + endif + + let startPos = searchpos('[;{}]\|\%^', 'bWn') + let curPos = getpos('.')[1:2] + " We don't want the character under the cursor + let column = curPos[1]-1 + let curPos[1] = (column<1)?1:column + return omni#cpp#tokenizer#Tokenize(omni#cpp#utils#GetCode(startPos, curPos)[1:] . szAppendText) +endfunc + +" Tokenize the current instruction until the word under the cursor. +" @return list of tokens +function! omni#cpp#utils#TokenizeCurrentInstructionUntilWord() + let startPos = searchpos('[;{}]\|\%^', 'bWn') + + " Saving the current cursor pos + let originalPos = getpos('.') + + " We go at the end of the word + execute 'normal gee' + let curPos = getpos('.')[1:2] + + " Restoring the original cursor pos + call setpos('.', originalPos) + + let szCode = omni#cpp#utils#GetCode(startPos, curPos)[1:] + return omni#cpp#tokenizer#Tokenize(szCode) +endfunc + +" Build parenthesis groups +" add a new key 'group' in the token +" where value is the group number of the parenthesis +" eg: (void*)(MyClass*) +" group1 group0 +" if a parenthesis is unresolved the group id is -1 +" @return a copy of a:tokens with parenthesis group +function! omni#cpp#utils#BuildParenthesisGroups(tokens) + let tokens = copy(a:tokens) + let kinds = {'(': '()', ')' : '()', '[' : '[]', ']' : '[]', '<' : '<>', '>' : '<>', '{': '{}', '}': '{}'} + let unresolved = {'()' : [], '[]': [], '<>' : [], '{}' : []} + let groupId = 0 + + " Note: we build paren group in a backward way + " because we can often have parenthesis unbalanced + " instruction + " eg: doSomething(_member.get()-> + for token in reverse(tokens) + if index([')', ']', '>', '}'], token.value)>=0 + let token['group'] = groupId + call extend(unresolved[kinds[token.value]], [token]) + let groupId+=1 + elseif index(['(', '[', '<', '{'], token.value)>=0 + if len(unresolved[kinds[token.value]]) + let tokenResolved = remove(unresolved[kinds[token.value]], -1) + let token['group'] = tokenResolved.group + else + let token['group'] = -1 + endif + endif + endfor + + return reverse(tokens) +endfunc + +" Determine if tokens represent a C cast +" @return +" - itemCast +" - itemCppCast +" - itemVariable +" - itemThis +function! omni#cpp#utils#GetCastType(tokens) + " Note: a:tokens is not modified + let tokens = omni#cpp#utils#SimplifyParenthesis(omni#cpp#utils#BuildParenthesisGroups(a:tokens)) + + if tokens[0].value == '(' + return 'itemCast' + elseif index(['static_cast', 'dynamic_cast', 'reinterpret_cast', 'const_cast'], tokens[0].value)>=0 + return 'itemCppCast' + else + for token in tokens + if token.value=='this' + return 'itemThis' + endif + endfor + return 'itemVariable' + endif +endfunc + +" Remove useless parenthesis +function! omni#cpp#utils#SimplifyParenthesis(tokens) + "Note: a:tokens is not modified + let tokens = a:tokens + " We remove useless parenthesis eg: (((MyClass))) + if len(tokens)>2 + while tokens[0].value=='(' && tokens[-1].value==')' && tokens[0].group==tokens[-1].group + let tokens = tokens[1:-2] + endwhile + endif + return tokens +endfunc + +" Function create a type info +function! omni#cpp#utils#CreateTypeInfo(param) + let type = type(a:param) + return {'type': type, 'value':a:param} +endfunc + +" Extract type info from a tag item +" eg: ::MyNamespace::MyClass +function! omni#cpp#utils#ExtractTypeInfoFromTag(tagItem) + let szTypeInfo = omni#cpp#utils#ExtractScope(a:tagItem) . '::' . substitute(a:tagItem.name, '.*::', '', 'g') + return omni#cpp#utils#SimplifyScope(szTypeInfo) +endfunc + +" Build a class inheritance list +function! omni#cpp#utils#GetClassInheritanceList(namespaces, typeInfo) + let result = [] + for tagItem in omni#cpp#utils#GetResolvedTags(a:namespaces, a:typeInfo) + call extend(result, [omni#cpp#utils#ExtractTypeInfoFromTag(tagItem)]) + endfor + return result +endfunc + +" Get class inheritance list where items in the list are tag items. +" TODO: Verify inheritance order +function! omni#cpp#utils#GetResolvedTags(namespaces, typeInfo) + let result = [] + let tagItem = omni#cpp#utils#GetResolvedTagItem(a:namespaces, a:typeInfo) + if tagItem!={} + let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTag(tagItem) + if has_key(g:omni#cpp#utils#CACHE_TAG_INHERITS, szTypeInfo) + let result = g:omni#cpp#utils#CACHE_TAG_INHERITS[szTypeInfo] + else + call extend(result, [tagItem]) + if has_key(tagItem, 'inherits') + for baseClassTypeInfo in split(tagItem.inherits, ',') + let namespaces = [omni#cpp#utils#ExtractScope(tagItem), '::'] + call extend(result, omni#cpp#utils#GetResolvedTags(namespaces, omni#cpp#utils#CreateTypeInfo(baseClassTypeInfo))) + endfor + endif + let g:omni#cpp#utils#CACHE_TAG_INHERITS[szTypeInfo] = result + endif + endif + return result +endfunc + +" Get a tag item after a scope resolution and typedef resolution +function! omni#cpp#utils#GetResolvedTagItem(namespaces, typeInfo) + let typeInfo = {} + if type(a:typeInfo) == 1 + let typeInfo = omni#cpp#utils#CreateTypeInfo(a:typeInfo) + else + let typeInfo = a:typeInfo + endif + + let result = {} + if !omni#cpp#utils#IsTypeInfoValid(typeInfo) + return result + endif + + " Unnamed type case eg: '1::2' + if typeInfo.type == 4 + " Here there is no typedef or namespace to resolve, the tagInfo.value is a tag item + " representing a variable ('v') a member ('m') or a typedef ('t') and the typename is + " always in global scope + return typeInfo.value + endif + + " Named type case eg: 'MyNamespace::MyClass' + let szTypeInfo = omni#cpp#utils#GetTypeInfoString(typeInfo) + + " Resolving namespace alias + " TODO: For the next release + "let szTypeInfo = omni#cpp#namespaces#ResolveAlias(g:omni#cpp#namespaces#CacheAlias, szTypeInfo) + + if szTypeInfo=='::' + return result + endif + + " We can only get members of class, struct, union and namespace + let szTagFilter = "index(['c', 's', 'u', 'n', 't'], v:val.kind[0])>=0" + let szTagQuery = szTypeInfo + + if s:IsTypeInfoResolved(szTypeInfo) + " The type info is already resolved, we remove the starting '::' + let szTagQuery = substitute(szTypeInfo, '^::', '', 'g') + if len(split(szTagQuery, '::'))==1 + " eg: ::MyClass + " Here we have to get tags that have no parent scope + " That's why we change the szTagFilter + let szTagFilter .= '&& ' . g:omni#cpp#utils#szFilterGlobalScope + let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') + call filter(tagList, szTagFilter) + if len(tagList) + let result = tagList[0] + endif + else + " eg: ::MyNamespace::MyClass + let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') + call filter(tagList, szTagFilter) + + if len(tagList) + let result = tagList[0] + endif + endif + else + " The type is not resolved + let tagList = omni#common#utils#TagListNoThrow('^'.szTagQuery.'$') + call filter(tagList, szTagFilter) + + if len(tagList) + " Resolving scope (namespace, nested class etc...) + let szScopeOfTypeInfo = s:ExtractScopeFromTypeInfo(szTypeInfo) + if s:IsTypeInfoResolved(szTypeInfo) + let result = s:GetTagOfSameScope(tagList, szScopeOfTypeInfo) + else + " For each namespace of the namespace list we try to get a tag + " that can be in the same scope + if g:OmniCpp_NamespaceSearch && &filetype != 'c' + for scope in a:namespaces + let szTmpScope = omni#cpp#utils#SimplifyScope(scope.'::'.szScopeOfTypeInfo) + let result = s:GetTagOfSameScope(tagList, szTmpScope) + if result!={} + break + endif + endfor + else + let szTmpScope = omni#cpp#utils#SimplifyScope('::'.szScopeOfTypeInfo) + let result = s:GetTagOfSameScope(tagList, szTmpScope) + endif + endif + endif + endif + + if result!={} + " We have our tagItem but maybe it's a typedef or an unnamed type + if result.kind[0]=='t' + " Here we can have a typedef to another typedef, a class, struct, union etc + " but we can also have a typedef to an unnamed type, in that + " case the result contains a 'typeref' key + let namespaces = [omni#cpp#utils#ExtractScope(result), '::'] + if has_key(result, 'typeref') + let result = omni#cpp#utils#GetResolvedTagItem(namespaces, omni#cpp#utils#CreateTypeInfo(result)) + else + let szCmd = omni#cpp#utils#ExtractCmdFromTagItem(result) + let szCode = substitute(omni#cpp#utils#GetCodeFromLine(szCmd), '\C\<'.result.name.'\>.*', '', 'g') + let szTypeInfo = omni#cpp#utils#ExtractTypeInfoFromTokens(omni#cpp#tokenizer#Tokenize(szCode)) + let result = omni#cpp#utils#GetResolvedTagItem(namespaces, omni#cpp#utils#CreateTypeInfo(szTypeInfo)) + " TODO: Namespace resolution for result + endif + endif + endif + + return result +endfunc + +" Returns if the type info is valid +" @return +" - 1 if valid +" - 0 otherwise +function! omni#cpp#utils#IsTypeInfoValid(typeInfo) + if a:typeInfo=={} + return 0 + else + if a:typeInfo.type == 1 && a:typeInfo.value=='' + " String case + return 0 + elseif a:typeInfo.type == 4 && a:typeInfo.value=={} + " Dictionary case + return 0 + endif + endif + return 1 +endfunc + +" Get the string of the type info +function! omni#cpp#utils#GetTypeInfoString(typeInfo) + if a:typeInfo.type == 1 + return a:typeInfo.value + else + return substitute(a:typeInfo.value.typeref, '^\w\+:', '', 'g') + endif +endfunc + +" A resolved type info starts with '::' +" @return +" - 1 if type info starts with '::' +" - 0 otherwise +function! s:IsTypeInfoResolved(szTypeInfo) + return match(a:szTypeInfo, '^::')!=-1 +endfunc + +" A returned type info's scope may not have the global namespace '::' +" eg: '::NameSpace1::NameSpace2::MyClass' => '::NameSpace1::NameSpace2' +" 'NameSpace1::NameSpace2::MyClass' => 'NameSpace1::NameSpace2' +function! s:ExtractScopeFromTypeInfo(szTypeInfo) + let szScope = substitute(a:szTypeInfo, '\w\+$', '', 'g') + if szScope =='::' + return szScope + else + return substitute(szScope, '::$', '', 'g') + endif +endfunc + +" @return +" - the tag with the same scope +" - {} otherwise +function! s:GetTagOfSameScope(listTags, szScopeToMatch) + for tagItem in a:listTags + let szScopeOfTag = omni#cpp#utils#ExtractScope(tagItem) + if szScopeOfTag == a:szScopeToMatch + return tagItem + endif + endfor + return {} +endfunc + +" Extract the cmd of a tag item without regexp +function! omni#cpp#utils#ExtractCmdFromTagItem(tagItem) + let line = a:tagItem.cmd + let re = '\(\/\^\)\|\(\$\/\)' + if match(line, re)!=-1 + let line = substitute(line, re, '', 'g') + return line + else + " TODO: the cmd is a line number + return '' + endif +endfunc + +" Extract type from tokens. +" eg: examples of tokens format +" 'const MyClass&' +" 'const map < int, int >&' +" 'MyNs::MyClass' +" '::MyClass**' +" 'MyClass a, *b = NULL, c[1] = {}; +" 'hello(MyClass a, MyClass* b' +" @return the type info string eg: ::std::map +" can be empty +function! omni#cpp#utils#ExtractTypeInfoFromTokens(tokens) + let szResult = '' + let state = 0 + + let tokens = omni#cpp#utils#BuildParenthesisGroups(a:tokens) + + " If there is an unbalanced parenthesis we are in a parameter list + let bParameterList = 0 + for token in tokens + if token.value == '(' && token.group==-1 + let bParameterList = 1 + break + endif + endfor + + if bParameterList + let tokens = reverse(tokens) + let state = 0 + let parenGroup = -1 + for token in tokens + if state==0 + if token.value=='>' + let parenGroup = token.group + let state=1 + elseif token.kind == 'cppWord' + let szResult = token.value.szResult + let state=2 + elseif index(['*', '&'], token.value)<0 + break + endif + elseif state==1 + if token.value=='<' && token.group==parenGroup + let state=0 + endif + elseif state==2 + if token.value=='::' + let szResult = token.value.szResult + let state=3 + else + break + endif + elseif state==3 + if token.kind == 'cppWord' + let szResult = token.value.szResult + let state=2 + else + break + endif + endif + endfor + return szResult + endif + + for token in tokens + if state==0 + if token.value == '::' + let szResult .= token.value + let state = 1 + elseif token.kind == 'cppWord' + let szResult .= token.value + let state = 2 + " Maybe end of token + endif + elseif state==1 + if token.kind == 'cppWord' + let szResult .= token.value + let state = 2 + " Maybe end of token + else + break + endif + elseif state==2 + if token.value == '::' + let szResult .= token.value + let state = 1 + else + break + endif + endif + endfor + return szResult +endfunc + +" Get the preview window string +function! omni#cpp#utils#GetPreviewWindowStringFromTagItem(tagItem) + let szResult = '' + + let szResult .= 'name: '.a:tagItem.name."\n" + for tagKey in keys(a:tagItem) + if index(['name', 'static'], tagKey)>=0 + continue + endif + let szResult .= tagKey.': '.a:tagItem[tagKey]."\n" + endfor + + return substitute(szResult, "\n$", '', 'g') +endfunc diff --git a/.vim/c-support/codesnippets/Makefile b/.vim/c-support/codesnippets/Makefile new file mode 100644 index 0000000..4b02b54 --- /dev/null +++ b/.vim/c-support/codesnippets/Makefile @@ -0,0 +1,204 @@ +#=============================================================================== +# +# Filename: Makefile +# Description: +# +# Usage: make (generate executable ) +# make clean (remove objects, executable, prerequisits ) +# make tarball (generate compressed archive ) +# make zip (generate compressed archive ) +# +# Version: 1.0 +# Created: +# Revision: --- +# +# Author: +# Company: +# Email: +# +# Notes: This is a GNU make (gmake) makefile. +# C extension : c +# C++ extensions : cc cpp C +# C and C++ sources can be mixed. +# Prerequisites are generated automatically; makedepend is not +# needed (see documentation for GNU make Version 3.80, July 2002, +# section 4.13). The utility sed is used. +#========================================== makefile template version 1.8 ====== + +# DEBUG can be set to YES to include debugging info, or NO otherwise +DEBUG := YES + +# PROFILE can be set to YES to include profiling info, or NO otherwise +PROFILE := NO + +# ------------ name of the executable ---------------------------------------- +EXECUTABLE := main + +# ------------ list of all source files -------------------------------------- +SOURCES := main.c + +# ------------ compiler ------------------------------------------------------ +CC := gcc +CXX := g++ + +# ------------ compiler flags ------------------------------------------------ +DEBUG_CFLAGS := -Wall -ansi -pedantic -O0 -g +RELEASE_CFLAGS := -Wall -ansi -pedantic -O3 + +# ------------ linker flags -------------------------------------------------- +DEBUG_LDFLAGS := -g +RELEASE_LDFLAGS := + +ifeq (YES, ${DEBUG}) + CFLAGS := ${DEBUG_CFLAGS} + CXXFLAGS := ${DEBUG_CXXFLAGS} + LDFLAGS := ${DEBUG_LDFLAGS} +else + CFLAGS := ${RELEASE_CFLAGS} + CXXFLAGS := ${RELEASE_CXXFLAGS} + LDFLAGS := ${RELEASE_LDFLAGS} +endif + +ifeq (YES, ${PROFILE}) + CFLAGS := ${CFLAGS} -pg -O3 + CXXFLAGS := ${CXXFLAGS} -pg -O3 + LDFLAGS := ${LDFLAGS} -pg +endif + +# ------------ additional system include directories ------------------------- +GLOBAL_INC_DIR = + +# ------------ private include directories ----------------------------------- +LOCAL_INC_DIR = $(HOME)/include + +# ------------ system libraries (e.g. -lm ) --------------------------------- +SYS_LIBS = -lm + +# ------------ additional system library directories ------------------------- +GLOBAL_LIB_DIR = + +# ------------ additional system libraries ----------------------------------- +GLOBAL_LIBS = + +# ------------ private library directories ----------------------------------- +LOCAL_LIB_DIR = $(HOME)/lib + +# ------------ private libraries (e.g. libxyz.a ) --------------------------- +LOCAL_LIBS = + +# ------------ archive generation --------------------------------------------- +TARBALL_EXCLUDE = *.{o,gz,zip} +ZIP_EXCLUDE = *.{o,gz,zip} + +# ------------ run executable out of this Makefile (yes/no) ----------------- +# ------------ cmd line parameters for this executable ----------------------- +EXE_START = no +EXE_CMDLINE = + +#=============================================================================== +# The following statements usually need not to be changed +#=============================================================================== + +C_SOURCES = $(filter %.c, $(SOURCES)) +CPP_SOURCES = $(filter-out %.c, $(SOURCES)) +ALL_INC_DIR = $(addprefix -I, $(LOCAL_INC_DIR) $(GLOBAL_INC_DIR)) +ALL_LIB_DIR = $(addprefix -L, $(LOCAL_LIB_DIR) $(GLOBAL_LIB_DIR)) +GLOBAL_LIBSS = $(addprefix $(GLOBAL_LIB_DIR)/, $(GLOBAL_LIBS)) +LOCAL_LIBSS = $(addprefix $(LOCAL_LIB_DIR)/, $(LOCAL_LIBS)) +ALL_CFLAGS = $(CFLAGS) $(ALL_INC_DIR) +ALL_LFLAGS = $(LDFLAGS) $(ALL_LIB_DIR) +BASENAMES = $(basename $(SOURCES)) + +# ------------ generate the names of the object files ------------------------ +OBJECTS = $(addsuffix .o,$(BASENAMES)) + +# ------------ generate the names of the hidden prerequisite files ----------- +PREREQUISITES = $(addprefix .,$(addsuffix .d,$(BASENAMES))) + +# ------------ make the executable (the default goal) ------------------------ +$(EXECUTABLE): $(OBJECTS) +ifeq ($(strip $(CPP_SOURCES)),) + $(CC) $(ALL_LFLAGS) -o $(EXECUTABLE) $(OBJECTS) $(LOCAL_LIBSS) $(GLOBAL_LIBSS) $(SYS_LIBS) +else + $(CXX) $(ALL_LFLAGS) -o $(EXECUTABLE) $(OBJECTS) $(LOCAL_LIBSS) $(GLOBAL_LIBSS) $(SYS_LIBS) +endif +ifeq ($(EXE_START),yes) + ./$(EXECUTABLE) $(EXE_CMDLINE) +endif + +# ------------ include the automatically generated prerequisites ------------- +# ------------ if target is not clean, tarball or zip ------------- +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),tarball) +ifneq ($(MAKECMDGOALS),zip) +include $(PREREQUISITES) +endif +endif +endif + +# ------------ make the objects ---------------------------------------------- +%.o: %.c + $(CC) -c $(ALL_CFLAGS) $< + +%.o: %.cc + $(CXX) -c $(ALL_CFLAGS) $< + +%.o: %.cpp + $(CXX) -c $(ALL_CFLAGS) $< + +%.o: %.C + $(CXX) -c $(ALL_CFLAGS) $< + +# ------------ make the prerequisites ---------------------------------------- +# +.%.d: %.c + @$(make-prerequisite-c) + +.%.d: %.cc + @$(make-prerequisite-cplusplus) + +.%.d: %.cpp + @$(make-prerequisite-cplusplus) + +.%.d: %.C + @$(make-prerequisite-cplusplus) + +# canned command sequences +# echoing of the sed command is suppressed by the leading @ + +define make-prerequisite-c + @$(CC) -MM $(ALL_CFLAGS) $< > $@.$$$$; \ + sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' < $@.$$$$ > $@; \ + rm -f $@.$$$$; +endef + +define make-prerequisite-cplusplus + @$(CXX) -MM $(ALL_CFLAGS) $< > $@.$$$$; \ + sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' < $@.$$$$ > $@; \ + rm -f $@.$$$$; +endef + +# ------------ remove generated files ---------------------------------------- +# ------------ remove hidden backup files ------------------------------------ +clean: + -rm --force $(EXECUTABLE) $(OBJECTS) $(PREREQUISITES) *~ + +# ------------ tarball generation ---------------------------------------------- +tarball: + @lokaldir=`pwd`; lokaldir=$${lokaldir##*/}; \ + rm --force $$lokaldir.tar.gz; \ + tar --exclude=$(TARBALL_EXCLUDE) \ + --create \ + --gzip \ + --verbose \ + --file $$lokaldir.tar.gz * + +# ------------ zip ------------------------------------------------------------- +zip: + @lokaldir=`pwd`; lokaldir=$${lokaldir##*/}; \ + zip -r $$lokaldir.zip * -x $(ZIP_EXCLUDE) + +.PHONY: clean tarball zip + +# ============================================================================== +# vim: set tabstop=2: set shiftwidth=2: diff --git a/.vim/c-support/codesnippets/Makefile.multi-target.template b/.vim/c-support/codesnippets/Makefile.multi-target.template new file mode 100644 index 0000000..75da8dd --- /dev/null +++ b/.vim/c-support/codesnippets/Makefile.multi-target.template @@ -0,0 +1,70 @@ +#=============================================================================== +# +# File: Makefile +# Description: +# +# Usage: make (generate executable(s) ) +# make clean (remove objects, executables, prerequisits ) +# make tarball (generate compressed archive ) +# make zip (generate compressed archive ) +# +# Author: Dr.-Ing. Fritz Mehner +# Email: mehner@mfh-iserlohn.de +# Created: +# +#=============================================================================== + + +CC = gcc +CCP = g++ +CFLAGS = -c -g -Wall +LFLAGS = -g +SYS_LIBS = -lm +TARBALL_EXCLUDE = "*.{o,gz,zip}" +ZIP_EXCLUDE = *.o *.gz *.zip + +TARGETS = target_1 target_2 + +#---------- targets -------------------------------------- +all: $(TARGETS) + +%.o: %.c + $(CC) $(CFLAGS) $*.c + +%.o: %.cc + $(CCP) $(CFLAGS) $*.cc + +#---------- target 1 ------------------------------------- +# C target +target_1: target_1.o + $(CC) $(LFLAGS) -o $@ $@.o $(SYS_LIBS) + +#---------- target 2 ------------------------------------- +# C++ target +target_2: target_2.o + $(CCP) $(LFLAGS) -o $@ $@.o $(SYS_LIBS) + + +#---------- target 3 ------------------------------------- + + + +#---------- tarball -------------------------------------- +tarball: + lokaldir=`pwd`; lokaldir=$${lokaldir##*/}; \ + rm --force $$lokaldir.tar.gz; \ + tar --exclude=$(TARBALL_EXCLUDE) \ + --create \ + --gzip \ + --verbose \ + --file $$lokaldir.tar.gz * + +#---------- zip ------------------------------------------ +zip: + lokaldir=`pwd`; lokaldir=$${lokaldir##*/}; \ + zip -r $$lokaldir.zip * -x $(ZIP_EXCLUDE) + +#---------- clear up ------------------------------------- +clean: + rm --force $(EXECUTABLE) $(OBJECTS) $(PREREQUISITES) + diff --git a/.vim/c-support/codesnippets/calloc_double_matrix.c b/.vim/c-support/codesnippets/calloc_double_matrix.c new file mode 100644 index 0000000..ec71658 --- /dev/null +++ b/.vim/c-support/codesnippets/calloc_double_matrix.c @@ -0,0 +1,36 @@ + +/* + * === FUNCTION ====================================================================== + * Name: calloc_double_matrix + * Description: Allocate a dynamic double-matrix of size rows*columns; + * return a pointer. + * ===================================================================================== + */ + double** +calloc_double_matrix ( int rows, int columns ) +{ + int i; + double **m; + m = calloc ( rows, sizeof(double*) ); /* allocate pointer array */ + assert( m != NULL); /* abort if allocation failed */ + *m = calloc ( rows*columns, sizeof(double) );/* allocate data array */ + assert(*m != NULL); /* abort if allocation failed */ + for ( i=1; i<rows; i+=1 ) /* set pointers */ + m[i] = m[i-1] + columns; + return m; +} /* ---------- end of function calloc_double_matrix ---------- */ + +/* + * === FUNCTION ====================================================================== + * Name: free_matrix_double + * Description: Free a dynamic double-matrix. + * ===================================================================================== + */ + void +free_double_matrix ( double **m ) +{ + free(*m); /* free data array */ + free( m); /* free pointer array */ + return ; +} /* ---------- end of function free_double_matrix ---------- */ + diff --git a/.vim/c-support/codesnippets/calloc_int_matrix.c b/.vim/c-support/codesnippets/calloc_int_matrix.c new file mode 100644 index 0000000..e21215b --- /dev/null +++ b/.vim/c-support/codesnippets/calloc_int_matrix.c @@ -0,0 +1,35 @@ + +/* + * === FUNCTION ====================================================================== + * Name: calloc_int_matrix + * Description: Allocate a dynamic int-matrix of size rows*columns; return a pointer. + * ===================================================================================== + */ +int** +calloc_int_matrix ( int rows, int columns ) +{ + int i; + int **m; + m = calloc ( rows, sizeof(int*) ); /* allocate pointer array */ + assert( m != NULL ); /* abort if allocation failed */ + *m = calloc ( rows*columns, sizeof(int) ); /* allocate data array */ + assert(*m != NULL ); /* abort if allocation failed */ + for ( i=1; i<rows; i+=1 ) /* set pointers */ + m[i] = m[i-1] + columns; + return m; +} /* ---------- end of function calloc_int_matrix ---------- */ + +/* + * === FUNCTION ====================================================================== + * Name: free_int_matrix + * Description: Free a dynamic int-matrix. + * ===================================================================================== + */ +void +free_int_matrix ( int **m ) +{ + free(*m); /* free data array */ + free( m); /* free pointer array */ + return ; +} /* ---------- end of function free_int_matrix ---------- */ + diff --git a/.vim/c-support/codesnippets/main.c b/.vim/c-support/codesnippets/main.c new file mode 100644 index 0000000..770f5d5 --- /dev/null +++ b/.vim/c-support/codesnippets/main.c @@ -0,0 +1,20 @@ +#include <errno.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +/* + * === FUNCTION ====================================================================== + * Name: main + * Description: main function + * ===================================================================================== + */ + int +main ( int argc, char *argv[] ) +{ + printf ("\nProgram %s\n\n", argv[0] ); + + return EXIT_SUCCESS; +} /* ---------- end of function main ---------- */ + diff --git a/.vim/c-support/codesnippets/main.cc b/.vim/c-support/codesnippets/main.cc new file mode 100644 index 0000000..f3060ef --- /dev/null +++ b/.vim/c-support/codesnippets/main.cc @@ -0,0 +1,19 @@ +#include <cstdlib> +#include <fstream> +#include <iomanip> +#include <iostream> + +using namespace std; + +// === FUNCTION ====================================================================== +// Name: main +// Description: main function +// ===================================================================================== + int +main ( int argc, char *argv[] ) +{ + cout << "\nProgram " << argv[0] << endl << endl; + + return EXIT_SUCCESS; +} // ---------- end of function main ---------- + diff --git a/.vim/c-support/codesnippets/print_array.cc.noindent b/.vim/c-support/codesnippets/print_array.cc.noindent new file mode 100644 index 0000000..52c43d3 --- /dev/null +++ b/.vim/c-support/codesnippets/print_array.cc.noindent @@ -0,0 +1,29 @@ + +// === FUNCTION ====================================================================== +// Name: print_array +// Description: Print an array with one dimension. +// Use +// print_array<T,w>( *matrix, n1*n2, n2, "matrix" ); +// for +// T matrix[n1][n2]; +// ===================================================================================== + template <class T, int width> +void print_array ( T *array, // array to print + int n, // number of elements to print + int nrow, // number of elements per row + string arrayname // array name + ) +{ + string line(" index | content\n ------+-"); + + cout << "\n\n array \"" << arrayname << "\", length " << n << endl << endl; + cout << line.append(width*nrow, '-'); + for ( int i=0; i<n; i+=1 ) { + if( i%nrow == 0 ) + cout << endl << setw(6) << i << " | "; + cout << "" << setw(width) << fixed << setprecision(2) << array[i]; + } + cout << endl << endl; + return ; +} // ---------- end of function print_double_array ---------- + diff --git a/.vim/c-support/codesnippets/print_double_array.c.noindent b/.vim/c-support/codesnippets/print_double_array.c.noindent new file mode 100644 index 0000000..c6bea02 --- /dev/null +++ b/.vim/c-support/codesnippets/print_double_array.c.noindent @@ -0,0 +1,34 @@ + +/* + * === FUNCTION ====================================================================== + * Name: print_double_array + * Description: Print a double-array with one dimension. + * Use + * print_int_array( *matrix, n1*n2, n2, "matrix" ); + * for + * double matrix[n1][n2]; + * ===================================================================================== + */ +static void +print_double_array ( double array[], /* array to print */ + int n, /* number of elements to print */ + int nrow, /* number of elements per row */ + char *arrayname /* array name */ + ) +{ + int i; + printf ("\n\n array \"%s\", length %d\n", arrayname, n ); + printf ("\n index | content\n" ); + printf ( " ------+-" ); + for ( i = 0; i < nrow; i += 1 ) + printf ( "---------" ); + for ( i=0; i<n; i+=1 ) + { + if( i%nrow == 0 ) + printf ("\n%6d | ", i ); + printf (" %8.2f", array[i] ); + } + printf ("\n\n"); + return ; +} /* ---------- end of function print_double_array ---------- */ + diff --git a/.vim/c-support/codesnippets/print_int_array.c.noindent b/.vim/c-support/codesnippets/print_int_array.c.noindent new file mode 100644 index 0000000..fc32043 --- /dev/null +++ b/.vim/c-support/codesnippets/print_int_array.c.noindent @@ -0,0 +1,34 @@ + +/* + * === FUNCTION ====================================================================== + * Name: print_int_array + * Description: Print an int-array with one dimension. + * Use + * print_int_array( *matrix, n1*n2, n2, "matrix" ); + * for + * int matrix[n1][n2]; + * ===================================================================================== + */ +static void +print_int_array ( int array[], /* array to print */ + int n, /* number of elements to print */ + int nrow, /* number of elements per row */ + char *arrayname /* array name */ + ) +{ + int i; + printf ("\n\n array \"%s\", length %d\n", arrayname, n ); + printf ("\n index | content\n" ); + printf ( " ------+-" ); + for ( i = 0; i < nrow; i += 1 ) + printf ( "-------" ); + for ( i=0; i<n; i+=1 ) + { + if( i%nrow == 0 ) + printf ("\n%6d | ", i ); + printf (" %6d", array[i] ); + } + printf ("\n\n"); + return ; +} /* ---------- end of function print_int_array ---------- */ + diff --git a/.vim/c-support/doc/ChangeLog b/.vim/c-support/doc/ChangeLog new file mode 100644 index 0000000..25176da --- /dev/null +++ b/.vim/c-support/doc/ChangeLog @@ -0,0 +1,398 @@ +================================================================================ + RELEASE NOTES FOR VERSION 5.9 +================================================================================ ++ Two additional hotkeys (+ ex commands) for preprocessor statements. ++ Compile-link-run: improved error detection. ++ Menu Run: hardcopy can print any buffer. ++ Several minor improvements and bugfixes. + +================================================================================ + RELEASE NOTES FOR VERSION 5.8 +================================================================================ ++ Hotkeys are shown in the menus. ++ File browser for code snippets and templates choosable (2 global variables). ++ Two new hotkeys: include file description (implementation, header). ++ New menu item: namespace alias ++ Bugfix: wrapper script for use of a xterm could not handle parameters containing blanks. ++ Several minor improvements. + +================================================================================ + RELEASE NOTES FOR VERSION 5.7 +================================================================================ ++ 4 new hotkeys : insert file section comments (C/C++/H), special comments, + keyword comments. ++ Adjusting end-of-line comment adjustment improved. + +================================================================================ + RELEASE NOTES FOR VERSION 5.6 +================================================================================ ++ Jump targets (templates) and mapping Ctrl-j can be switched off. ++ Yet unused jump targets will be highlighted after a file is opened. ++ Statements menu: else block (key mapping \se). ++ Handling of <SPLIT> improved (templates). ++ Minor improvements. + +================================================================================ + RELEASE NOTES FOR VERSION 5.5 +================================================================================ ++ Additional plugin-tags (jump targets in templates): <+text+>, <-text->. ++ Additional mapping Ctrl-j : jump to these new targets. ++ Template-file: additional macro |STYLE| and IF-ENDIF-construct to easily + choose between sets of templates. ++ Additional mapping: auto-complete classical C comment (also multi-line). ++ Additional mapping: auto-complete open block starting with {<CR> . ++ Visual mode for date and time insertion (menu 'Comments'). ++ Visual mode for tags (submenu 'Comments->tags (plugin)'). ++ Bugfix: hotkey \ica not working ++ Bugfix: hotkey Shift-F2 for the alternate-plugin disappeared. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.4 +======================================================================================= ++ New hotkey \+co inserts ' cout << << endl;' ++ New menu item C++-menu: 'cout' replaces 'cout variable' and 'cout string'. ++ Hotkey \c/ removed ( \cc does the same). ++ Bugfix: after an unsuccessful compilation screen sometimes garbled. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.3 +======================================================================================= ++ Insertions work properly when folding is used. ++ Menu items Idioms->for(...) : type declaration for loop variable possible (tab completion). ++ Specification of command line arguments (Run->cmd. line arg.): filename completion active. ++ New main menu item 'show manual' (hotkey \hm): read manual for word under cursor. ++ One hotkey renamed: \h -> \hp (help plugin) + +======================================================================================= + RELEASE NOTES FOR VERSION 5.2.1 +======================================================================================= ++ Bugfix: stray characters whith three dialogs ++ Bugfix: Missing parameter in 2 internal function calls ++ Menu items 'Snippets->edit local/global templates' start an file browser (convenience). + +======================================================================================= + RELEASE NOTES FOR VERSION 5.2 +======================================================================================= ++ Superfluous control characters for mode switching (menus, hotkeys) removed. Caused beeps. ++ Template files (local/global) can be opened from the snippet menu. ++ Three new preprocessor statements. ++ v-mode for RTTI-entries. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.1 +======================================================================================= ++ Definition and implementation of classes have now different templates and menu entries. ++ Accessor methods (get/set) can be generated. ++ New templates: everything other than language keywords comes from a template + (and is user changeable). + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0.5 +======================================================================================= ++ Bugfix: on a few systems doubling of path components in the run command (F9). + Skip this upgrade if you do not have this problem. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0.4 +======================================================================================= ++ Format for the macros |DATE|, |TIME|, and |YEAR| can be defined by the user. ++ Help text improved. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0.3 +======================================================================================= ++ Code snippets can now be used in the console mode (Vim without GUI). ++ Bugfix: Possible conflict with 'indent' removed when inserting templates. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0.2 +======================================================================================= ++ Bugfix: Prototype picker did not alway delete no longer used prototypes. ++ Bugfix: Prototype picker removed template specializations from parameter lists. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0.1 +======================================================================================= ++ Bugfix: autocmd setting can influence autocmd settings of OTHER plugins. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0 +======================================================================================= ++ Completely new template system. Now every menu item is user definable. ++ Changes to allow a system-wide installation. ++ A few hotkeys added and renamed. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.6.1 +======================================================================================= ++ New global variable to control the filetype of *.h header files (default is now 'cpp'). ++ Bugfix: properly resetting 'compiler' after using make, splint, and CodeCheck. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.6 +======================================================================================= ++ New insert mode mappings (comments, statements, preprocessing, idioms, C++). ++ Some mappings renamed (easier to remember). ++ New tag (basename of a file reduced to characters allowed in names). + +======================================================================================= + RELEASE NOTES FOR VERSION 4.5 +======================================================================================= ++ New menu item and hotkey for the (re)alignement of end-of-line comments. ++ Hotkey \cn removed. Only one menu item for end-of-line comments left. ++ Changed hotkeys: \ce -> \cl and \cl -> \cs . ++ Three new tags (giving the basename of a file) for writing template files. ++ Prototype picker handles template methods. ++ Bugfix: splint works now under Windows. ++ Minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.4 +======================================================================================= ++ Plugin directories rearranged. ++ main- and for-idiom have a visual mode now. ++ Four new commands (command line) to control the comment style. ++ Comment style (C/C++) can automatically follow the filetype. ++ Bugfix: empty new file after removing the header template can't be closed. ++ Bugfix : Tools entry missing when root menu not shown from the start. ++ Minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.3 +======================================================================================= ++ CodeCheck (TM) integrated (source code analysing tool). ++ New key mappings for preprocessor statements. ++ New preprocessor menu. ++ Bugfix: indent under Windows. ++ Minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.2.1 +======================================================================================= ++ Bugfix: change needed for some menu names after patch 7.0.054 . + +======================================================================================= + RELEASE NOTES FOR VERSION 4.2 +======================================================================================= ++ Setting the starting column for trailing comments improved. ++ Small bug in block uncommenting fixed. ++ Mac OS X : circumvent a Vim bug which caused a crash when loading plugin version 4.1. ++ File syntax/c.vim removed (but see help in csupport.txt). + +======================================================================================= + RELEASE NOTES FOR VERSION 4.1 +======================================================================================= ++ A complete switch statement can be made from a list of labels. ++ Additional cases can be made from a list of labels. ++ Small bug in line end commenting fixed. ++ Some minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.0 +======================================================================================= + ++ Kernighan & Ritchie style for block statements can be enabled. ++ Changes to make it compatible with Vim 7. ++ Set C/C++ file type for source files which should not be preprocessed (*.i, *.ii). ++ Some minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.11 +======================================================================================= + ++ Hotkeys and an accompanying reference card added. ++ Preparation for syntax based folding. ++ Some minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.10 +======================================================================================= + ++ Remove "#if 0 ... #endif" from the inside. ++ Change C comments to C++ comments and vice versa. ++ try..catch / catch / catch(...) now can be set surround a marked area. ++ Prototype picking improved (for C++). ++ A hardcopy shows the localized date and time in the header line. ++ New help menu entry in the main menu of this plugin (shows the plugin documentation). ++ Switch between corresponding source and header files with <S-F2> if the plugin a.vim + is present. ++ Plugin can be used with autocompletion for (, [, and { . + +======================================================================================= + RELEASE NOTES FOR VERSION 3.9.1 +======================================================================================= + ++ Doubling of file header for new c- and h-files under Windows fixed (Thanks to + Fabricio C A Oliveira). ++ Tiny bug in the file open idioms fixed. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.9 +======================================================================================= + ++ Formatter 'indent' integrated. ++ Bugfix in the automatic header insertion. ++ Assert idiom added. ++ #if 0 ... #endif statement for blocking out code added. ++ Minor stylistic improvements in some idioms. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.8.2 +======================================================================================= + ++ Screen update problem solved: color inversion under FC4 (Thanks to Bernie Barton). ++ RTTI menu : additional v-mode. ++ Statement menu and C++ menu rearranged. ++ Include guard : name generation improved. ++ File header templates will be included for additional file extensions (cp, cxx, c++, ...). + +======================================================================================= + RELEASE NOTES FOR VERSION 3.8.1 +======================================================================================= + ++ More C++ output manipulators, manipulator insertion more intuitive. ++ Output into buffer: cursor goes to top of file. ++ Makefile template improved (code snippet). ++ Some internal improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.8 +======================================================================================= + ++ Windows support. Most features are now available under Windows. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.7.2 +======================================================================================= + ++ Run buffer through splint (A tool for statically checking C programs; see + http://www.splint.org). An error window will be opened; quickfix commands can be used. ++ Set buffer related command line arguments for splint. ++ Line end comments start in a fixed column (can be set from the menu). ++ Spaces in path names and file names are now possible. ++ Template files and snippet files are no longer kept in the list of alternate files. ++ Some minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.7.1 +======================================================================================= + ++ Bug fixed (command line arguments not passed to the executable). ++ File extension for executables can be set. ++ Minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.7 +======================================================================================= + ++ Running a program: + (1) Run program from the gVim command line. + (2) Run program and direct the output into a window with name "C-Output". + This buffer and its content will disappear when closing the window. + The buffer is reused when still open. + (3) Run program in an xterm (adjustable). ++ Command line arguments are now buffer related (each buffer can have its own arguments). ++ Code snippets can be protected from being indented during insertion. ++ Picked up prototypes will be deleted after insertion. ++ A code snippet with the file name extension "ni" or "noindent" will not be + indented on insertion. ++ for- and calloc-/malloc-idioms improved. ++ Bug fixed (word list handling). + + +======================================================================================= + RELEASE NOTES FOR VERSION 3.6 +======================================================================================= + ++ Installation simplified. ++ for-loop-idiom asks for control variable, initial value, ... ++ malloc-idiom asks for pointer variable and size. ++ Toggling the comment style works correct again. ++ Empty error windows will be closed. ++ Prototype picker removes trailing parts of the function body if marked. ++ The dialog windows (GUI) have been replaced by more flexible command line inputs. ++ The undocumented and unnecessary hot key F12 has been removed. ++ Extension to ctags + taglist shows makefile targets and qmake targets. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.5 +======================================================================================= + ++ Aligned line end comments for consecutive lines. ++ Improved prototype picker removes comments. ++ Picked up prototypes can be shown. ++ Uncomment more than one block at once. ++ 3 new idioms. ++ Help file improved . + +======================================================================================= + RELEASE NOTES FOR VERSION 3.4 +======================================================================================= + ++ Two new global variables: C_Dictionary_File, C_MenuHeader . ++ The preprocessor statements #if... and the function idiom include marked + lines when invoked in visual mode. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.3 +======================================================================================= + ++ The C/C++ root menu can be disabled. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.2 +======================================================================================= + ++ Only one C/C++ entry in the gVim root menu. ++ All hotkeys are only defined for C/C++ files (file type plugin added). ++ The following constructs are now read as templates from files: + class, class using new, + template class, template class using new, + error class ++ Install script added. ++ Customization improved. ++ Documentation improved (help file added). ++ Bug fix (template file handling) + +======================================================================================= + RELEASE NOTES FOR VERSION 3.1 +======================================================================================= + ++ When the comment style "C" is active the menu entry "Comments.code->comment" + turns a marked region in one multiline C-comment. ++ The menu entry "Comments.comment->code" turns marked multiline C-comment + back into code. ++ A marked region can be surrounded by a for-, if, if-else, while-, do-while-statement + (with indentation). ++ The menu entry "Snippets.make prototype" makes a C- or C++-prototype from + the current line or marked region and puts it in an internal buffer. ++ The menu entry "Snippets.add prototype" also makes a C- or C++-prototype from + the current line or a marked region and adds it to the internal buffer. ++ The menu entry "Snippets.put prototype" inserts all gathered prototypes + below the current line. ++ Tag substitution rewritten (Some characters in a substitution text for a tag + prevented the tag from being substituted). + +======================================================================================= + RELEASE NOTES FOR VERSION 3.0 +======================================================================================= + ++ C-style comments AND C++-style comments are supported now. ++ The menu entry 'Comments->Comment style ..' switches the styles (toggle). ++ Block comments are now read as templates or skeletons from files: + Frame Block, Function Description, Method Description, + Class Description, H+file header, C/C++-file header ++ These templates can contain tags like |FILENAME|, |AUTHOR| etc. which are replaced + after reading (KDevelop templates can be used without any change). ++ indentation: multiline inserts and code snippets will be indented after insertion. ++ Most menu entries are now also active in normal mode. ++ new menu items: + includes for the C99 header, + includes for the standard C++ header, + includes for the C++ version of the Standard C Library header, + multiline C comment + vim modeline ++ Reading the templates is done in one function which can be called in an autocmd. ++ Code cleanup: register z no longer used. Most function calls are silent now. + + diff --git a/.vim/c-support/doc/c-hotkeys.pdf b/.vim/c-support/doc/c-hotkeys.pdf Binary files differnew file mode 100644 index 0000000..2ac88bc --- /dev/null +++ b/.vim/c-support/doc/c-hotkeys.pdf diff --git a/.vim/c-support/doc/c-hotkeys.tex b/.vim/c-support/doc/c-hotkeys.tex new file mode 100644 index 0000000..d8dc844 --- /dev/null +++ b/.vim/c-support/doc/c-hotkeys.tex @@ -0,0 +1,366 @@ +%%===================================================================================== +%% +%% File: c-hotkeys.tex +%% +%% Description: c-support.vim : Key mappings for Vim without GUI. +%% +%% +%% Author: Dr.-Ing. Fritz Mehner +%% Email: mehner@fh-swf.de +%% Copyright: Copyright (C) 2006-2010 Dr.-Ing. Fritz Mehner (mehner@fh-swf.de) +%% Version: 1.0 +%% Created: 10.11.2006 +%% Revision: $Id: c-hotkeys.tex,v 1.33 2010/02/05 13:21:43 mehner Exp $ +%% +%% Notes: +%% +%%===================================================================================== + +\documentclass[oneside,11pt,landscape,DIV16]{scrartcl} + +\usepackage[english]{babel} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{times} +\usepackage{lastpage} +\usepackage{multicol} +\usepackage{setspace} + +\setlength\parindent{0pt} + +\newcommand{\Pluginversion}{5.10} +\newcommand{\ReleaseDate}{ February 2010} + +%%---------------------------------------------------------------------- +%% luximono : Type1-font +%% Makes keyword stand out by using semibold letters. +%%---------------------------------------------------------------------- +\usepackage[scaled]{luximono} + +%%---------------------------------------------------------------------- +%% fancyhdr +%%---------------------------------------------------------------------- +\usepackage{fancyhdr} +\pagestyle{fancyplain} +\fancyfoot[L]{\small \ReleaseDate} +\fancyfoot[C]{c-support.vim} +\fancyfoot[R]{\small \textbf{Page \thepage{} / \pageref{LastPage}}} +\renewcommand{\headrulewidth}{0.0pt} + +%%---------------------------------------------------------------------- +%% hyperref +%%---------------------------------------------------------------------- +\usepackage[ps2pdf]{hyperref} +\hypersetup{pdfauthor={Dr.-Ing. Fritz Mehner, FH Südwestfalen, Iserlohn, Germany}} +\hypersetup{pdfkeywords={Vim, C/C++}} +\hypersetup{pdfsubject={Vim-plugin, c-support.vim, hot keys}} +\hypersetup{pdftitle={Vim-plugin, c-support.vim, hot keys}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% START OF DOCUMENT +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{document}% + +\begin{multicols}{3} +% +%%====================================================================== +%% title +%%====================================================================== +\begin{center} +\textbf{\textsc{\small{Vim-Plugin}}}\\ +\textbf{\LARGE{c-support.vim}}\\ +\textbf{\textsc{\small{Version \Pluginversion}}}\\ +\textbf{\textsc{\Huge{Hot keys}}}\\ +Key mappings for Vim with and without GUI.\\ +Plugin: http://vim.sourceforge.net\\ +\vspace{3.0mm} +{\normalsize (i)} insert mode, {\normalsize (n)} normal mode, {\normalsize (v)} visual mode\\ +\vspace{5.0mm} +% +%%====================================================================== +%% table, left part +%%====================================================================== +%%~~~~~ TABULAR : begin ~~~~~~~~~~ +\begin{tabular}[]{|p{10mm}|p{60mm}|} +% +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{C}omments}} \\ +\hline \verb'\cl' & end-of-line comment \hfill (n,v,i)\\ +\hline \verb'\cj' & adjust end-of-line comment \hfill (n,v,i)\\ +\hline \verb'\cs' & set end-of-line comment column \hfill (n) \\ +\hline \verb'\c*' & code $\Rightarrow$ comment \verb'/* */' \hfill (n,v) \\ +\hline \verb'\cc' & code $\Rightarrow$ comment \verb'//' \hfill (n,v) \\ +\hline \verb'\co' & comment $\Rightarrow$ code \hfill (n,v) \\ + +\hline \verb'\cfr' & frame comment \hfill (n,i)\\ +\hline \verb'\cfu' & function comment \hfill (n,i)\\ +\hline \verb'\cme' & method description \hfill (n,i)\\ +\hline \verb'\ccl' & class description \hfill (n,i)\\ +\hline \verb'\cfdi'& file description (implementation) \hfill (n,i)\\ +\hline \verb'\cfdh'& file description (header) \hfill (n,i)\\ + +\hline \verb'\ccs'& C/C++--file sections\hspace{3mm}\footnotesize{(tab compl.)} \hfill \normalsize{(n,i)}\\ +\hline \verb'\chs'& H--file sections\hspace{10mm}\footnotesize{(tab compl.)} \hfill \normalsize{(n,i)}\\ +\hline \verb'\ckc'& keyword comment\hspace{5mm}\footnotesize{(tab compl.)} \hfill \normalsize{(n,i)}\\ +\hline \verb'\csc'& special comment\hspace{7,5mm}\footnotesize{(tab compl.)} \hfill \normalsize{(n,i)}\\ + +\hline \verb'\cd' & date \hfill (n,v,i)\\ +\hline \verb'\ct' & date \& time \hfill (n,v,i)\\ +\hline +\end{tabular}\\ +%%~~~~~ TABULAR : end ~~~~~~~~~~ +% +%%====================================================================== +%% table, middle part +%%====================================================================== +% +%%~~~~~ TABULAR : begin ~~~~~~~~~~ +\begin{tabular}[]{|p{15mm}|p{55mm}|} +%%---------------------------------------------------------------------- +%% menu statements +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{S}tatements}} \\ +\hline \verb'\sd' & \verb'do { } while' \hfill (n,v,i)\\ +\hline \verb'\sf' & \verb'for' \hfill (n,i)\\ +\hline \verb'\sfo' & \verb'for { }' \hfill (n,v,i)\\ +\hline \verb'\si' & \verb'if' \hfill (n,i)\\ +\hline \verb'\sif' & \verb'if { }' \hfill (n,v,i)\\ +\hline \verb'\sie' & \verb'if else' \hfill (n,v,i)\\ +\hline \verb'\sife'& \verb'if { } else { }' \hfill (n,v,i)\\ +\hline \verb'\se' & \verb'else { }' \hfill (n,v,i)\\ +\hline \verb'\sw' & \verb'while' \hfill (n,i)\\ +\hline \verb'\swh' & \verb'while { }' \hfill (n,v,i)\\ +\hline \verb'\ss' & \verb'switch' \hfill (n,v,i)\\ +\hline \verb'\sc' & \verb'case' \hfill (n,i)\\ +\hline \verb'\s{ \sb' & \verb'{ }' \hfill (n,v,i)\\ +\hline +%%---------------------------------------------------------------------- +%% preprocessor menu +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{P}reprocessor}} \\ +\hline \verb'\ps' & choose a Std. Lib. include \hfill (n,i)\\ +\hline \verb'\pc' & choose a C99 include \hfill (n,i)\\ +\hline \verb'\p<' & \verb$#include<...>$ \hfill (n,i)\\ +\hline \verb'\p"' & \verb$#include"..."$ \hfill (n,i)\\ +\hline \verb'\pd' & \verb'#define' \hfill (n,i)\\ +\hline \verb'\pu' & \verb'#undef' \hfill (n,i)\\ +\hline \verb'\pie' & \verb'#if #else #endif' \hfill (n,v,i)\\ +\hline \verb'\pid' & \verb'#ifdef #else #endif' \hfill (n,v,i)\\ +\hline \verb'\pin' & \verb'#ifndef #else #endif' \hfill (n,v,i)\\ +\hline \verb'\pind' & \verb'#ifndef #def #endif' \hfill (n,v,i)\\ +\hline \verb'\pi0' & \verb'#if 0 #endif' \hfill (n,v,i)\\ +\hline \verb'\pr0' & remove \verb'#if 0 #endif' \hfill (n,i)\\ +\hline \verb'\pe' & \verb'#error ' \hfill (n,i)\\ +\hline \verb'\pl' & \verb'#line ' \hfill (n,i)\\ +\hline \verb'\pp' & \verb'#pragma' \hfill (n,i)\\ +\hline +\end{tabular} \\ +%%~~~~~ TABULAR : end ~~~~~~~~~~ + +%%====================================================================== +%% table, right part +%%====================================================================== +% +%%~~~~~ TABULAR : begin ~~~~~~~~~~ +\begin{tabular}[]{|p{11mm}|p{60mm}|} +%%---------------------------------------------------------------------- +%% snippet menu +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{S\textbf{n}ippet}} \\ +\hline \verb'\nr' & read code snippet \hfill (n,i)\\ +\hline \verb'\nw' & write code snippet \hfill (n,v,i)\\ +\hline \verb'\ne' & edit code snippet \hfill (n,i)\\ +\hline \verb'\np' & pick up prototype \hfill (n,v,i)\\ +\hline \verb'\ni' & insert prototype(s) \hfill (n,i)\\ +\hline \verb'\nc' & clear prototype(s) \hfill (n,i)\\ +\hline \verb'\ns' & show prototype(s) \hfill (n,i)\\ +% +\hline \verb'\ntl' & edit local templates \hfill (n,i)\\ +\hline \verb'\ntg' & edit global templates \hfill (n,i)\\ +\hline \verb'\ntr' & reread the templates \hfill (n,i)\\ +\hline \verb'\nts' & change templates style \hfill (n,i)\\ +\hline +%%---------------------------------------------------------------------- +%% idioms menu +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{I}dioms}} \\ +\hline \verb'\if' & function \hfill (n,v,i)\\ +\hline \verb'\isf' & static function \hfill (n,v,i)\\ +\hline \verb'\im' & \verb'main()' \hfill (n,v,i)\\ +\hline \verb'\i0' & \verb'for( x=0; x<n; x+=1 )' \hfill (n,v,i)\\ +\hline \verb'\in' & \verb'for( x=n-1; x>=0; x-=1 )' \hfill (n,v,i)\\ +\hline \verb'\ie' & \verb'enum' + \verb'typedef' \hfill (n,v,i)\\ +\hline \verb'\is' & \verb'struct' + \verb'typedef' \hfill (n,v,i)\\ +\hline \verb'\iu' & \verb'union' + \verb'typedef' \hfill (n,v,i)\\ +\hline \verb'\ip' & \verb'printf()' \hfill (n,i)\\ +\hline \verb'\isc' & \verb'scanf()' \hfill (n,i)\\ +\hline \verb'\ica' & \verb'p=calloc()' \hfill (n,i)\\ +\hline \verb'\ima' & \verb'p=malloc()' \hfill (n,i)\\ +\hline \verb'\isi' & \verb'sizeof()' \hfill (n,v,i)\\ +\hline \verb'\ias' & \verb'assert()' \hfill (n,v,i)\\ +\hline \verb'\ii' & open input file \hfill (n,v,i)\\ +\hline \verb'\io' & open output file \hfill (n,v,i)\\ +\hline +\end{tabular}\\ +% +%%====================================================================== +%% table, right part +%%====================================================================== +% +%%~~~~~ TABULAR : begin ~~~~~~~~~~ +\begin{tabular}[]{|p{12mm}|p{62mm}|} +%%---------------------------------------------------------------------- +%% C++ menu +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{C\textbf{+}+}} \\ +\hline \verb'\+co' & \verb'cout << << endl; ' \hfill (n,i)\\ +\hline \verb'\+c' & class \hfill (n,i)\\ +\hline \verb'\+ps' & \verb$#include<...> STL$ \hfill (n,i)\\ +\hline \verb'\+pc' & \verb$#include<c..> C$ \hfill (n,i)\\ +\hline \verb'\+cn' & class (using \verb'new') \hfill (n,i)\\ +\hline \verb'\+ci' & class implementation \hfill (n,i)\\ +\hline \verb'\+cni' & class (using \verb'new') implementation \hfill (n,i)\\ +\hline \verb'\+mi' & method implementation \hfill (n,i)\\ +\hline \verb'\+ai' & accessor implementation \hfill (n,i)\\ +\hline \verb'\+tc' & template class \hfill (n,i)\\ +\hline \verb'\+tcn' & template class (using \verb'new') \hfill (n,i)\\ +\hline \verb'\+tci' & template class implementation \hfill (n,i)\\ +\hline \verb'\+tcni'& template class (using \verb'new') impl. \hfill (n,i)\\ +\hline \verb'\+tmi' & template method implementation \hfill (n,i)\\ +\hline \verb'\+tai' & template accessor implementation \hfill (n,i)\\ +\hline \verb'\+tf' & template function \hfill (n,i)\\ +\hline \verb'\+ec' & error class \hfill (n,i)\\ +\hline \verb'\+tr' & \verb'try' \dots \verb'catch' \hfill (n,v,i)\\ +\hline \verb'\+ca' & \verb'catch' \hfill (n,v,i)\\ +\hline \verb'\+c.' & \verb'catch(...)' \hfill (n,v,i)\\ +\hline +%%---------------------------------------------------------------------- +%% run menu +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{R}un}} \\ +\hline \verb'\rc' & save and compile \hfill (n,i)\\ +\hline \verb'\rl' & link \hfill (n,i)\\ +\hline \verb'\rr' & run \hfill (n,i)\\ +\hline \verb'\ra' & set comand line arguments \hfill (n,i)\\ +\hline \verb'\rm' & run \texttt{make} \hfill (n,i)\\ +\hline \verb'\rg' & cmd.\ line arg.\ for \texttt{make} \hfill (n,i)\\ +% +\hline \verb'\rp' & run \texttt{splint}$^1$ \hfill (n,i)\\ +\hline \verb'\ri' & cmd.\ line arg.\ for \texttt{splint} \hfill (n,i)\\ +% +\hline \verb'\rk' & run \texttt{CodeCheck}$^2$ \hfill (n,i)\\ +\hline \verb'\re' & cmd.\ line arg.\ for \texttt{CodeCheck} \hfill (n,i)\\ +% +\hline \verb'\rd' & run \texttt{indent} \hfill (n,i)\\ +\hline \verb'\rh' & hardcopy buffer \hfill (n,i,v)\\ +\hline \verb'\rs' & show plugin settings \hfill (n,i)\\ +\hline \verb'\rx' & set xterm size \hfill (n,i, only Unix \& GUI)\\ +\hline \verb'\ro' & change output destination \hfill (n,i)\\ +\hline +\end{tabular} +% +%%---------------------------------------------------------------------- +%% load / unload menu entry +%%---------------------------------------------------------------------- +\begin{tabular}[]{|p{12mm}|p{52mm}|} +\hline +%\multicolumn{2}{|r|}{\textsl{Menu(s)}}\\ +%%---------------------------------------------------------------------- +%% show plugin help +%%---------------------------------------------------------------------- +%\hline +\multicolumn{2}{|r|}{\textsl{\textbf{H}elp and Menus}}\\ +\hline \verb'\hm' & show manual \hfill (n,i)\\ +\hline \verb'\hp' & help (c-support) \hfill (n,i)\\ +\hline \verb'\lcs' & load Menus\hfill \scriptsize{(n \& GUI only)}\\ +\hline \verb'\ucs' & unload Menus\hfill \scriptsize{(n \& GUI only)}\\ +\hline +\end{tabular} +%%~~~~~ TABULAR : end ~~~~~~~~~~ +% +% +\begin{minipage}[b]{66mm}% +\vspace{10mm} +% +\begin{flushleft} +% +\textit{Ex commands:} +\begin{description} +% +\item [CFileSection] +C/C++--file sections (same as \verb'\ccs') +% +\item [HFileSection] +H--file sections (same as \verb'\chs') +% +\item [KeywordComment] +keyword comment (same as \verb'\ckc') +% +\item [SpecialComment] +special comment (same as \verb'\csc') +% +\item [IncludeStdLibrary] +standard library includes (same as \verb'\ps') +% +\item [IncludeC99Library] +C99 includes (same as \verb'\pc') +% +\item [IncludeCppLibrary] +STL includes (same as \verb'\+ps') +% +\item [IncludeCppCLibrary] +C includes (same as \verb'\+pc') +% +\item [CStyle] +C99 include (same as \verb'\nts') +% +\end{description} +% +Use tab expansion to show the items to choose from. +% +\end{flushleft} +% +\end{minipage}\\ +% +\begin{minipage}[b]{64mm}% +\scriptsize{% +\vspace{10mm} +\hrulefill\\ +$^1$ {www.splint.org}\\ +$^2$ \textbf{CodeCheck}$^{TM}$ is a product of Abraxas Software, Inc. +}% +\end{minipage}\\ +% +\begin{minipage}[b]{64mm}% + +\setlength{\fboxsep}{.25mm} +%%---------------------------------------------------------------------- +%% Additional Mappings +%%---------------------------------------------------------------------- +\begin{spacing}{1.2} +\begin{tabular}[]{|p{12mm}|p{56mm}|} +\hline +\multicolumn{2}{|r|}{\textsl{Additional Mappings}}\\ +\hline +\hline \textbf{typing} & \textbf{expansion}\\ +\hline \verb'/*' & \verb'/* */' \hfill (i)\\ +\hline \verb'/*' & \verb'/* '\fbox{\small{(multiline) marked text}}\verb' */' \hfill (v)\\ +\hline \verb'/*<CR>' & \verb'/*'\hfill (i)\newline\verb' * |'\newline\verb' */'\\ +\hline \verb'{<CR>' & \verb'{'\hfill (i)\newline\verb' |'\newline\verb'}' \\ +\hline \verb'{<CR>' & \verb'{'\hfill (v)\newline\verb' '\fbox{\small{(multiline) marked text}}\newline\verb'}'\\ +\hline +\end{tabular} +\end{spacing} +%%~~~~~ TABULAR : end ~~~~~~~~~~ +% +\end{minipage}% +% +\end{center} +\end{multicols} +\end{document} diff --git a/.vim/c-support/rc/customization.ctags b/.vim/c-support/rc/customization.ctags new file mode 100644 index 0000000..323cbbc --- /dev/null +++ b/.vim/c-support/rc/customization.ctags @@ -0,0 +1,8 @@ + +--regex-make=/^([^:# \t]+)[ \t]*:($|[^=]+)/\1/t,targets/ +--regex-make=/^include[ \t]+(.+)/\1/i,includes/ + +--langdef=qmake +--langmap=qmake:+.pro +--regex-qmake=/^([[:upper:]_]+)/\1/t,SystemVariables/ + diff --git a/.vim/c-support/rc/customization.gvimrc b/.vim/c-support/rc/customization.gvimrc new file mode 100644 index 0000000..31befe7 --- /dev/null +++ b/.vim/c-support/rc/customization.gvimrc @@ -0,0 +1,57 @@ +"=================================================================================== +" FILE: .gvimrc +" DESCRIPTION: suggestion for a personal configuration file ~/.gvimrc +" AUTHOR: Dr.-Ing. Fritz Mehner +" VERSION: 1.0 +" CREATED: 04.04.2009 +" REVISION: $Id: customization.gvimrc,v 1.3 2009/04/04 08:26:21 mehner Exp $ +"=================================================================================== +" +"=================================================================================== +" GENERAL SETTINGS +"=================================================================================== +set cmdheight=2 " Make command line two lines high +set mousehide " Hide the mouse when typing text + +highlight Normal guibg=grey90 +highlight Cursor guibg=Blue guifg=NONE +highlight lCursor guibg=Cyan guifg=NONE +highlight NonText guibg=grey80 +highlight Constant gui=NONE guibg=grey95 +highlight Special gui=NONE guibg=grey95 +" +let c_comment_strings=1 " highlight strings inside C comments +" +"------------------------------------------------------------------------------- +" Moving cursor to other windows +" +" shift down : change window focus to lower one (cyclic) +" shift up : change window focus to upper one (cyclic) +" shift left : change window focus to one on left +" shift right : change window focus to one on right +"------------------------------------------------------------------------------- +nmap <s-down> <c-w>w +nmap <s-up> <c-w>W +nmap <s-left> <c-w>h +nmap <s-right> <c-w>l +" +"------------------------------------------------------------------------------- +" some additional hot keys +"------------------------------------------------------------------------------- +" S-F3 - call gvim file browser +"------------------------------------------------------------------------------- + map <silent> <s-F3> :silent browse confirm e<CR> +imap <silent> <s-F3> <Esc>:silent browse confirm e<CR> +" +"------------------------------------------------------------------------------- +" toggle insert mode <--> 'normal mode with the <RightMouse>-key +"------------------------------------------------------------------------------- +" +nmap <RightMouse> <Insert> +imap <RightMouse> <ESC> +" +"------------------------------------------------------------------------------- +" use font with clearly distinguishable brackets : ()[]{} +"------------------------------------------------------------------------------- +"set guifont=Luxi\ Mono\ 14 +" diff --git a/.vim/c-support/rc/customization.indent.pro b/.vim/c-support/rc/customization.indent.pro new file mode 100644 index 0000000..95f6081 --- /dev/null +++ b/.vim/c-support/rc/customization.indent.pro @@ -0,0 +1,8 @@ +--blank-lines-after-procedures +--brace-indent0 +--comment-indentation49 +--declaration-comment-column49 +--declaration-indentation10 +--space-after-parentheses +--swallow-optional-blank-lines +--tab-size2 diff --git a/.vim/c-support/rc/customization.vimrc b/.vim/c-support/rc/customization.vimrc new file mode 100644 index 0000000..917018a --- /dev/null +++ b/.vim/c-support/rc/customization.vimrc @@ -0,0 +1,222 @@ +"=================================================================================== +" FILE: .vimrc +" DESCRIPTION: suggestion for a personal configuration file ~/.vimrc +" AUTHOR: Dr.-Ing. Fritz Mehner +" CREATED: 04.04.2009 +" REVISION: $Id: customization.vimrc,v 1.6 2009/10/03 12:24:30 mehner Exp $ +"=================================================================================== +" +"=================================================================================== +" GENERAL SETTINGS +"=================================================================================== + +"------------------------------------------------------------------------------- +" Use Vim settings, rather then Vi settings. +" This must be first, because it changes other options as a side effect. +"------------------------------------------------------------------------------- +set nocompatible +" +"------------------------------------------------------------------------------- +" Enable file type detection. Use the default filetype settings. +" Also load indent files, to automatically do language-dependent indenting. +"------------------------------------------------------------------------------- +filetype plugin on +filetype indent on +" +"------------------------------------------------------------------------------- +" Switch syntax highlighting on. +"------------------------------------------------------------------------------- +syntax on +" +" Platform specific items: +" - central backup directory (has to be created) +" - default dictionary +" Uncomment your choice. +if has("win16") || has("win32") || has("win64") || + \ has("win95") || has("win32unix") + " +" runtime mswin.vim +" set backupdir =$VIM\vimfiles\backupdir +" set dictionary=$VIM\vimfiles\wordlists/german.list +else +" set backupdir =$HOME/.vim.backupdir +" set dictionary=$HOME/.vim/wordlists/german.list +endif +" +" Using a backupdir under UNIX/Linux: you may want to include a line similar to +" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; +" in one of your shell startup files (e.g. $HOME/.profile) +" +"------------------------------------------------------------------------------- +" Various settings +"------------------------------------------------------------------------------- +set autoindent " copy indent from current line +set autoread " read open files again when changed outside Vim +set autowrite " write a modified buffer on each :next , ... +set backspace=indent,eol,start " backspacing over everything in insert mode +set backup " keep a backup file +set browsedir=current " which directory to use for the file browser +set complete+=k " scan the files given with the 'dictionary' option +set history=50 " keep 50 lines of command line history +set hlsearch " highlight the last used search pattern +set incsearch " do incremental searching +set listchars=tab:>.,eol:\$ " strings to use in 'list' mode +set mouse=a " enable the use of the mouse +set nowrap " do not wrap lines +set popt=left:8pc,right:3pc " print options +set ruler " show the cursor position all the time +set shiftwidth=2 " number of spaces to use for each step of indent +set showcmd " display incomplete commands +set smartindent " smart autoindenting when starting a new line +set tabstop=2 " number of spaces that a <Tab> counts for +set visualbell " visual bell instead of beeping +set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions +set wildmenu " command-line completion in an enhanced mode +" +"=================================================================================== +" BUFFERS, WINDOWS +"=================================================================================== +" +"------------------------------------------------------------------------------- +" The current directory is the directory of the file in the current window. +"------------------------------------------------------------------------------- +if has("autocmd") + autocmd BufEnter * :lchdir %:p:h +endif +" +"------------------------------------------------------------------------------- +" close window (conflicts with the KDE setting for calling the process manager) +"------------------------------------------------------------------------------- + noremap <C-Esc> :close<CR> +inoremap <C-Esc> <C-C>:close<CR> +" +"------------------------------------------------------------------------------- +" Fast switching between buffers +" The current buffer will be saved before switching to the next one. +" Choose :bprevious or :bnext +"------------------------------------------------------------------------------- + noremap <silent> <s-tab> :if &modifiable && !&readonly && + \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> +inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && + \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> +" +"------------------------------------------------------------------------------- +" Leave the editor with Ctrl-q (KDE): Write all changed buffers and exit Vim +"------------------------------------------------------------------------------- +nnoremap <C-q> :wqall<CR> +" +"------------------------------------------------------------------------------- +" When editing a file, always jump to the last known cursor position. +" Don't do it when the position is invalid or when inside an event handler +" (happens when dropping a file on gvim). +"------------------------------------------------------------------------------- +if has("autocmd") + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif +endif " has("autocmd") +" +"------------------------------------------------------------------------------- +" some additional hot keys +"------------------------------------------------------------------------------- +" F2 - write file without confirmation +" F3 - call file explorer Ex +" F4 - show tag under curser in the preview window (tagfile must exist!) +" F5 - open quickfix error window +" F6 - close quickfix error window +" F7 - display previous error +" F8 - display next error +"------------------------------------------------------------------------------- +" +map <silent> <F2> :write<CR> +map <silent> <F3> :Explore<CR> +nmap <silent> <F4> :exe ":ptag ".expand("<cword>")<CR> +map <silent> <F5> :copen<CR> +map <silent> <F6> :cclose<CR> +map <silent> <F7> :cp<CR> +map <silent> <F8> :cn<CR> +" +imap <silent> <F2> <Esc>:write<CR> +imap <silent> <F3> <Esc>:Explore<CR> +imap <silent> <F4> <Esc>:exe ":ptag ".expand("<cword>")<CR> +imap <silent> <F5> <Esc>:copen<CR> +imap <silent> <F6> <Esc>:cclose<CR> +imap <silent> <F7> <Esc>:cp<CR> +imap <silent> <F8> <Esc>:cn<CR> +" +"------------------------------------------------------------------------------- +" Fast switching between buffers +" The current buffer will be saved before switching to the next one. +" Choose :bprevious or :bnext +"------------------------------------------------------------------------------- +" + map <silent> <s-tab> <Esc>:if &modifiable && !&readonly && + \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> +imap <silent> <s-tab> <Esc>:if &modifiable && !&readonly && + \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> +" +"------------------------------------------------------------------------------- +" Leave the editor with Ctrl-q : Write all changed buffers and exit Vim +"------------------------------------------------------------------------------- +nmap <C-q> :wqa<CR> +" +"------------------------------------------------------------------------------- +" comma always followed by a space +"------------------------------------------------------------------------------- +inoremap , ,<Space> +" +"------------------------------------------------------------------------------- +" autocomplete parenthesis, brackets and braces +"------------------------------------------------------------------------------- +inoremap ( ()<Left> +inoremap [ []<Left> +inoremap { {}<Left> +" +vnoremap ( s()<Esc>P<Right>% +vnoremap [ s[]<Esc>P<Right>% +vnoremap { s{}<Esc>P<Right>% +" +"------------------------------------------------------------------------------- +" autocomplete quotes (visual and select mode) +"------------------------------------------------------------------------------- +xnoremap ' s''<Esc>P<Right> +xnoremap " s""<Esc>P<Right> +xnoremap ` s``<Esc>P<Right> +" +"------------------------------------------------------------------------------- +" Change the working directory to the directory containing the current file +"------------------------------------------------------------------------------- +if has("autocmd") + autocmd BufEnter * :lchdir %:p:h +endif " has("autocmd") +" +"=================================================================================== +" VARIOUS PLUGIN CONFIGURATIONS +"=================================================================================== +" +"------------------------------------------------------------------------------- +" c.vim +"------------------------------------------------------------------------------- +" +" --empty -- +" +"------------------------------------------------------------------------------- +" taglist.vim : toggle the taglist window +" taglist.vim : define the title texts for make +" taglist.vim : define the title texts for qmake +"------------------------------------------------------------------------------- + noremap <silent> <F11> <Esc><Esc>:Tlist<CR> +inoremap <silent> <F11> <Esc><Esc>:Tlist<CR> + +let Tlist_GainFocus_On_ToggleOpen = 1 +let Tlist_Close_On_Select = 1 + +let tlist_make_settings = 'make;m:makros;t:targets' +let tlist_qmake_settings = 'qmake;t:SystemVariables' + +if has("autocmd") + " ---------- qmake : set filetype for *.pro ---------- + autocmd BufNewFile,BufRead *.pro set filetype=qmake +endif " has("autocmd") + diff --git a/.vim/c-support/scripts/wrapper.sh b/.vim/c-support/scripts/wrapper.sh new file mode 100755 index 0000000..f78861c --- /dev/null +++ b/.vim/c-support/scripts/wrapper.sh @@ -0,0 +1,30 @@ +#!/bin/bash +#=============================================================================== +# FILE: wrapper.sh +# USAGE: ./wrapper.sh executable [cmd-line-args] +# DESCRIPTION: Wraps the execution of a programm or script. +# Use with xterm: xterm -e wrapper.sh executable cmd-line-args +# This script is used by the plugins c.vim +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Dr.-Ing. Fritz Mehner (Mn), mehner@fh-swf.de +# COMPANY: Fachhochschule Südwestfalen, Iserlohn +# CREATED: 23.11.2004 18:04:01 CET +# REVISION: $Id: wrapper.sh,v 1.5 2009/06/03 17:47:06 mehner Exp $ +#=============================================================================== + +executable="${1}" # name of the executable + +if [ ${#} -ge 1 ] && [ -x "$executable" ] +then + "${@}" + returncode=$? + [ $returncode -ne 0 ] && printf "'${@}' returned ${returncode}\n" +else + printf "\n !! file \"${executable}\" does not exist or is not executable !!\n" + returncode=126 # command invoked cannot execute +fi +read -p " ... press return key ... " dummy +exit $returncode diff --git a/.vim/c-support/templates/Templates b/.vim/c-support/templates/Templates new file mode 100644 index 0000000..5841481 --- /dev/null +++ b/.vim/c-support/templates/Templates @@ -0,0 +1,30 @@ +$ +$ ============================================================= +$ ========== USER MACROS ====================================== +$ ============================================================= +$ +|AUTHOR| = bryan newbold +|AUTHORREF| = bnewbold +|EMAIL| = bnewbold@robocracy.org +|COMPANY| = +|COPYRIGHT| = Copyright (c) |YEAR|, |AUTHOR| +|STYLE| = default +$ +$ ============================================================= +$ ========== FILE INCLUDES ==================================== +$ ============================================================= +$ +|includefile| = c.comments.template +|includefile| = c.cpp.template +|includefile| = c.idioms.template +|includefile| = c.preprocessor.template +|includefile| = c.statements.template +$ +== IF |STYLE| IS CPP == +|includefile| = cpp.comments.template +|includefile| = cpp.cpp.template +|includefile| = cpp.idioms.template +|includefile| = cpp.preprocessor.template +|includefile| = cpp.statements.template +== ENDIF == +$ diff --git a/.vim/c-support/templates/c.comments.template b/.vim/c-support/templates/c.comments.template new file mode 100644 index 0000000..a500103 --- /dev/null +++ b/.vim/c-support/templates/c.comments.template @@ -0,0 +1,160 @@ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.end-of-line-comment == append == +/* <CURSOR> */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.frame == +/*--------------------------------------------------------------------------- + * <CURSOR> + *---------------------------------------------------------------------------*/ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.function == +/* + * === FUNCTION ============================================================= + * Name: |?FUNCTION_NAME| + * Description: <CURSOR> + * ============================================================================ + */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.method == +/* + *----------------------------------------------------------------------------- + * Class: |?CLASSNAME| + * Method: |?CLASSNAME| :: |?METHODNAME| + * Description: <CURSOR> + *----------------------------------------------------------------------------- + */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.class == +/* + * ============================================================================ + * Class: |?CLASSNAME| + * Description: <CURSOR> + * ============================================================================ + */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-description == start == +/*----------------------------------------------------------------------------- + * + * Filename: |FILENAME| + * Author: |AUTHOR| (|AUTHORREF|), |EMAIL| + * Created: |DATE| |TIME| + * Description: <CURSOR> + * + *---------------------------------------------------------------------------*/ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-description-header == start == +/*----------------------------------------------------------------------------- + * + * Filename: |FILENAME| + * Author: |AUTHOR| (|AUTHORREF|), |EMAIL| + * Created: |DATE| |TIME| + * Description: <CURSOR> + * + *---------------------------------------------------------------------------*/ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-header-includes == +/* ##### HEADER FILE INCLUDES ########################################## */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-macros == +/* ##### MACROS - LOCAL TO THIS SOURCE FILE ########################## */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-typedefs == +/* ##### TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE ################ */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-data-types == +/* ##### DATA TYPES - LOCAL TO THIS SOURCE FILE ###################### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-class-defs == +/* ##### CLASS DEFINITIONS - LOCAL TO THIS SOURCE FILE ############### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-local-variables == +/* ##### VARIABLES - LOCAL TO THIS SOURCE FILE ####################### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-prototypes == +/* ##### PROTOTYPES - LOCAL TO THIS SOURCE FILE ###################### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-function-defs-exported == +/* ##### FUNCTION DEFINITIONS - EXPORTED FUNCTIONS ################### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-function-defs-local == +/* ##### FUNCTION DEFINITIONS - LOCAL TO THIS SOURCE FILE ############ */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-class-implementations-exported == +/* ##### CLASS IMPLEMENTATIONS - EXPORTED CLASSES #################### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-class-implementations-local == +/* ##### CLASS IMPLEMENTATIONS - LOCAL CLASSES ####################### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-header-includes == +/* ##### HEADER FILE INCLUDES ########################################## */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-macros == +/* ##### EXPORTED MACROS ############################################### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-exported-typedefs == +/* ##### EXPORTED TYPE DEFINITIONS ##################################### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-exported-data-types == +/* ##### EXPORTED DATA TYPES ########################################### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-exported-class-defs == +/* ##### EXPORTED CLASS DEFINITIONS #################################### */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-exported-variables == +/* ##### EXPORTED VARIABLES ############################################ */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-exported-function-declarations == +/* ##### EXPORTED FUNCTION DECLARATIONS ################################ */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.keyword-bug == append == + /* :BUG:|DATE| |TIME|:|AUTHORREF|: <CURSOR> */ +== comment.keyword-compiler == append == + /* :COMPILER:|DATE| |TIME|:|AUTHORREF|: <CURSOR> */ +== comment.keyword-todo == append == + /* :TODO:|DATE| |TIME|:|AUTHORREF|: <CURSOR> */ +== comment.keyword-tricky == append == + /* :TRICKY:|DATE| |TIME|:|AUTHORREF|: <CURSOR> */ +== comment.keyword-warning == append == + /* :WARNING:|DATE| |TIME|:|AUTHORREF|: <CURSOR> */ +== comment.keyword-workaround == append == + /* :WORKAROUND:|DATE| |TIME|:|AUTHORREF|: <CURSOR> */ +== comment.keyword-keyword == append == + /* :|?KEYWORD:u|:|DATE| |TIME|:|AUTHORREF|: <CURSOR> */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.special-empty == append == + /* EMPTY */<CURSOR> +== comment.special-fall-through == append == + /* FALL THROUGH */<CURSOR> +== comment.special-implicit-type-conversion == append == + /* IMPLICIT TYPE CONVERSION */<CURSOR> +== comment.special-no-return == append == + /* NO RETURN */<CURSOR> +== comment.special-not-reached == append == + /* NOT REACHED */<CURSOR> +== comment.special-remains-to-be-implemented == append == + /* REMAINS TO BE IMPLEMENTED */<CURSOR> +== comment.special-constant-type-is-long == append == + /* constant type is long */<CURSOR> +== comment.special-constant-type-is-unsigned == append == + /* constant type is unsigned */<CURSOR> +== comment.special-constant-type-is-unsigned-long == append == + /* constant type is unsigned long */<CURSOR> +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/.vim/c-support/templates/c.cpp.template b/.vim/c-support/templates/c.cpp.template new file mode 100644 index 0000000..97b9082 --- /dev/null +++ b/.vim/c-support/templates/c.cpp.template @@ -0,0 +1,487 @@ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +$ +== cpp.cin == +cin >> <CURSOR>; +$ +== cpp.cout == +cout << <CURSOR> << endl; +$ +== cpp.cout-operator == insert == +<< "<CURSOR>" +$ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.output-manipulator-boolalpha == insert == +<< boolalpha <CURSOR> +== cpp.output-manipulator-dec == insert == +<< dec <CURSOR> +== cpp.output-manipulator-endl == insert == +<< endl <CURSOR> +== cpp.output-manipulator-fixed == insert == +<< fixed <CURSOR> +== cpp.output-manipulator-flush == insert == +<< flush <CURSOR> +== cpp.output-manipulator-hex == insert == +<< hex <CURSOR> +== cpp.output-manipulator-internal == insert == +<< internal <CURSOR> +== cpp.output-manipulator-left == insert == +<< left <CURSOR> +== cpp.output-manipulator-oct == insert == +<< oct <CURSOR> +== cpp.output-manipulator-right == insert == +<< right <CURSOR> +== cpp.output-manipulator-scientific == insert == +<< scientific <CURSOR> +== cpp.output-manipulator-setbase == insert == +<< setbase(10<CURSOR>) +== cpp.output-manipulator-setfill == insert == +<< setfill(<CURSOR>) +== cpp.output-manipulator-setiosflag == insert == +<< setiosflags(<CURSOR>) +== cpp.output-manipulator-setprecision == insert == +<< setprecision(6<CURSOR>) +== cpp.output-manipulator-setw == insert == +<< setw(0<CURSOR>) +== cpp.output-manipulator-showbase == insert == +<< showbase <CURSOR> +== cpp.output-manipulator-showpoint == insert == +<< showpoint <CURSOR> +== cpp.output-manipulator-showpos == insert == +<< showpos <CURSOR> +== cpp.output-manipulator-uppercase == insert == +<< uppercase <CURSOR> +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.method-implementation == +void<CURSOR> +|?CLASSNAME|::|?METHODNAME| ( <+argument list+> ) +{ + return ; +} /* ----- end of method |CLASSNAME|::|?METHODNAME| ----- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.accessor-implementation == +/* + *----------------------------------------------------------------------------- + * Class: |?CLASSNAME| + * Method: get_|?ATTRIBUTE| + *----------------------------------------------------------------------------- + */ +inline int<CURSOR> +|CLASSNAME|::get_|ATTRIBUTE| ( ) +{ + return |ATTRIBUTE|; +} /* ----- end of method |CLASSNAME|::get_|ATTRIBUTE| ----- */ + +/* + *----------------------------------------------------------------------------- + * Class: |CLASSNAME| + * Method: set_|ATTRIBUTE| + *----------------------------------------------------------------------------- + */ +inline void +|CLASSNAME|::set_|ATTRIBUTE| ( <+argument list+> ) +{ + |ATTRIBUTE| = value; + return ; +} /* ----- end of method |CLASSNAME|::set_|ATTRIBUTE| ----- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.class-definition == +/* + * ============================================================================ + * Class: |?CLASSNAME:c| + * Description: <CURSOR> + * ============================================================================ + */ +class |CLASSNAME| +{ + public: + /* ==================== LIFECYCLE ============================== */ + |CLASSNAME| (); /* constructor */ + + /* ==================== ACCESSORS ============================== */ + + /* ==================== MUTATORS ============================== */ + + /* ==================== OPERATORS ============================== */ + + protected: + /* ==================== DATA MEMBERS ============================== */ + + private: + /* ==================== DATA MEMBERS ============================== */ + +}; /* ----- end of class |CLASSNAME| ----- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.class-implementation == +/* + *----------------------------------------------------------------------------- + * Class: |?CLASSNAME:c| + * Method: |CLASSNAME| + * Description: constructor + *----------------------------------------------------------------------------- + */ +|CLASSNAME|::|CLASSNAME| () +{<CURSOR> +} /* ----- end of method |CLASSNAME|::|CLASSNAME| (constructor) ----- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.class-using-new-definition == +/* + * ============================================================================ + * Class: |?CLASSNAME:c| + * Description: <CURSOR> + * ============================================================================ + */ +class |CLASSNAME| +{ + public: + + /* ==================== LIFECYCLE ============================== */ + |CLASSNAME| (); /* constructor */ + |CLASSNAME| ( const |CLASSNAME| &other ); /* copy constructor */ + ~|CLASSNAME| (); /* destructor */ + + /* ==================== ACCESSORS ============================== */ + + /* ==================== MUTATORS ============================== */ + + /* ==================== OPERATORS ============================== */ + + |CLASSNAME|& operator = ( const |CLASSNAME| &other ); /* assignment operator */ + + protected: + /* ==================== DATA MEMBERS ============================== */ + + private: + /* ==================== DATA MEMBERS ============================== */ + +}; /* ----- end of class |CLASSNAME| ----- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.class-using-new-implementation == +/* + *----------------------------------------------------------------------------- + * Class: |?CLASSNAME:c| + * Method: |CLASSNAME| + * Description: constructor + *----------------------------------------------------------------------------- + */ +|CLASSNAME|::|CLASSNAME| () +{<CURSOR> +} /* ----- end of method |CLASSNAME|::|CLASSNAME| (constructor) ----- */ + +/* + *----------------------------------------------------------------------------- + * Class: |CLASSNAME| + * Method: |CLASSNAME| + * Description: copy constructor + *----------------------------------------------------------------------------- + */ +|CLASSNAME|::|CLASSNAME| ( const |CLASSNAME| &other ) +{ +} /* ----- end of method |CLASSNAME|::|CLASSNAME| (copy constructor) ----- */ + +/* + *----------------------------------------------------------------------------- + * Class: |CLASSNAME| + * Method: ~|CLASSNAME| + * Description: destructor + *----------------------------------------------------------------------------- + */ +|CLASSNAME|::~|CLASSNAME| () +{ +} /* ----- end of method |CLASSNAME|::~|CLASSNAME| (destructor) ----- */ + +/* + *----------------------------------------------------------------------------- + * Class: |CLASSNAME| + * Method: operator = + * Description: assignment operator + *----------------------------------------------------------------------------- + */ +|CLASSNAME|& +|CLASSNAME|::operator = ( const |CLASSNAME| &other ) +{ + if ( this != &other ) { + } + return *this; +} /* ----- end of method |CLASSNAME|::operator = (assignment operator) ----- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.error-class == +/* + * ============================================================================ + * Class: |?CLASSNAME:c| + * Description: <CURSOR> + * ============================================================================ + */ +class |CLASSNAME| +{ + public: |CLASSNAME| ( string msg = "|CLASSNAME|" ):message(msg) { } + virtual ~|CLASSNAME| ( ) { } + virtual string what ( ) const throw ( ) { return message; } + protected: string message; +}; /* ----- end of class |CLASSNAME| ----- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-method-implementation == +template < class T > +void<CURSOR> |?CLASSNAME|<T>::|?METHODNAME| ( <+argument list+> ) +{ + return ; +} /* ----- end of method |CLASSNAME|<T>::|METHODNAME| ----- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-accessor-implementation == +/* + *----------------------------------------------------------------------------- + * Class: |?CLASSNAME| + * Method: get_|?ATTRIBUTE| + *----------------------------------------------------------------------------- + */ +template < class T > +inline int<CURSOR> |CLASSNAME|<T>::get_|ATTRIBUTE| ( ) +{ + return |ATTRIBUTE|; +} /* ----- end of method |CLASSNAME|<T>::get_|ATTRIBUTE| ----- */ + +/* + *----------------------------------------------------------------------------- + * Class: |CLASSNAME| + * Method: set_|ATTRIBUTE| + *----------------------------------------------------------------------------- + */ +template < class T > +inline void |CLASSNAME|<T>::set_|ATTRIBUTE| ( <+argument list+> ) +{ + |ATTRIBUTE| = value; + return ; +} /* ----- end of method |CLASSNAME|<T>::set_|ATTRIBUTE| ----- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-class-definition == +/* + * ============================================================================ + * Class: |?CLASSNAME:c| + * Description: <CURSOR> + * ============================================================================ + */ +template < class T > +class |CLASSNAME| +{ + public: + + /* ==================== LIFECYCLE ============================== */ + |CLASSNAME| (); /* constructor */ + + /* ==================== ACCESSORS ============================== */ + + /* ==================== MUTATORS ============================== */ + + /* ==================== OPERATORS ============================== */ + + protected: + /* ==================== DATA MEMBERS ============================== */ + + private: + /* ==================== DATA MEMBERS ============================== */ + +}; /* ---------- end of template class |CLASSNAME| ---------- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-class-implementation == +/* + *----------------------------------------------------------------------------- + * Class: |?CLASSNAME:c| + * Method: |CLASSNAME| + * Description: + *----------------------------------------------------------------------------- + */ +template < class T > +|CLASSNAME| < T >::|CLASSNAME| () +{<CURSOR> +} /* ---------- end of constructor of template class |CLASSNAME| ---------- */ + + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-class-using-new-definition == +/* + * ============================================================================ + * Class: |?CLASSNAME:c| + * Description: <CURSOR> + * ============================================================================ + */ + +template < class T > +class |CLASSNAME| +{ + public: + + // ==================== LIFECYCLE ============================== + |CLASSNAME| (); /* constructor */ + |CLASSNAME| ( const |CLASSNAME| &other ); /* copy constructor */ + ~|CLASSNAME| (); /* destructor */ + + /* ==================== ACCESSORS ============================== */ + + /* ==================== MUTATORS ============================== */ + + /* ==================== OPERATORS ============================== */ + + |CLASSNAME|& operator = ( const |CLASSNAME| &other ); // assignment operator + + protected: + /* ==================== DATA MEMBERS ============================== */ + + private: + /* ==================== DATA MEMBERS ============================== */ + +}; /* ----- end of template class |CLASSNAME| ----- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-class-using-new-implementation == +/* + *----------------------------------------------------------------------------- + * Class: |?CLASSNAME:c| + * Method: |CLASSNAME| + * Description: constructor + *----------------------------------------------------------------------------- + */ +template < class T > +|CLASSNAME|< T >::|CLASSNAME| () +{<CURSOR> +} /* ---------- end of constructor of template class |CLASSNAME| ---------- */ + +/* + *----------------------------------------------------------------------------- + * Class: |CLASSNAME| + * Method: |CLASSNAME| + * Description: copy constructor + *----------------------------------------------------------------------------- + */ +template < class T > +|CLASSNAME|< T >::|CLASSNAME| ( const |CLASSNAME| &other ) +{ +} /* ---------- end of copy constructor of template class |CLASSNAME| ---------- */ + +/* + *----------------------------------------------------------------------------- + * Class: |CLASSNAME| + * Method: ~|CLASSNAME| + * Description: destructor + *----------------------------------------------------------------------------- + */ +template < class T > +|CLASSNAME|< T >::~|CLASSNAME| () +{ +} /* ---------- end of destructor of template class |CLASSNAME| ---------- */ + +/* + *----------------------------------------------------------------------------- + * Class: |CLASSNAME| + * Method: operator = + * Description: assignment operator + *----------------------------------------------------------------------------- + */ +template < class T > +|CLASSNAME|< T >& |CLASSNAME|< T >::operator = ( const |CLASSNAME| &other ) +{ + return *this; +} /* ---------- end of assignment operator of template class |CLASSNAME| ---------- */ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-function == +template <class T> +void<CURSOR> |?TEMPALTE_FUNCTION_NAME| ( <+argument list+> ) +{ + return ; +} /* ----- end of template function |?TEMPALTE_FUNCTION_NAME| ----- */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.operator-in == +ostream & +operator << ( ostream & os, const |?CLASSNAME| & obj ) +{ + os << obj.<CURSOR> ; + return os; +} /* ----- end of function operator << ----- */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.operator-out == +istream & +operator >> ( istream & is, |?CLASSNAME| & obj ) +{ + is >> obj.<CURSOR> ; + return is; +} /* ----- end of function operator >> ----- */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.try-catch == +try { +<SPLIT>} +catch ( const <CURSOR> &ExceptObj ) { /* handle exception: */ +} +catch (...) { /* handle exception: unspecified */ +} + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.catch == +catch ( <CURSOR>const &ExceptObj ) { /* handle exception: */ +<SPLIT>} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.catch-points == +catch (...) { /* handle exception: */ +<SPLIT>} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.extern == +extern "C" {<CURSOR> +<SPLIT>} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.open-input-file == +char *ifs_file_name = "<CURSOR>"; /* input file name */ +ifstream ifs; /* create ifstream object */ + +ifs.open (ifs_file_name); /* open ifstream */ +if (!ifs) { + cerr << "\nERROR : failed to open input file " << ifs_file_name << endl; + exit (EXIT_FAILURE); +} +<SPLIT>{-continue here-} +ifs.close (); /* close ifstream */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.open-output-file == +char *ofs_file_name = "<CURSOR>"; /* output file name */ +ofstream ofs; /* create ofstream object */ + +ofs.open (ofs_file_name); /* open ofstream */ +if (!ofs) { + cerr << "\nERROR : failed to open output file " << ofs_file_name << endl; + exit (EXIT_FAILURE); +} +<SPLIT>{-continue here-} +ofs.close (); /* close ofstream */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.namespace-std == +using namespace std; +== cpp.namespace == +using namespace |?NAMESPACE|; +== cpp.namespace-block == +namespace |?NAMESPACE| {<CURSOR> +<SPLIT>} /* ----- end of namespace |NAMESPACE| ----- */ +== cpp.namespace-alias == +namespace |?NAMESPACE_ALIAS| = {-original namespace name-}; +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.rtti-typeid == insert == +typeid(<CURSOR><SPLIT>) +$ +== cpp.rtti-static-cast == insert == +static_cast<>(<CURSOR><SPLIT>) +$ +== cpp.rtti-const-cast == insert == +const_cast<>(<CURSOR><SPLIT>) +$ +== cpp.rtti-reinterpret-cast == insert == +reinterpret_cast<>(<CURSOR><SPLIT>) +$ +== cpp.rtti-dynamic-cast == insert == +dynamic_cast<>(<CURSOR><SPLIT>) +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/.vim/c-support/templates/c.idioms.template b/.vim/c-support/templates/c.idioms.template new file mode 100644 index 0000000..4565fab --- /dev/null +++ b/.vim/c-support/templates/c.idioms.template @@ -0,0 +1,133 @@ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.function == +/* + * === FUNCTION ====================================================================== + * Name: |?FUNCTION_NAME| + * Description: + * ===================================================================================== + */ +void<CURSOR> +|FUNCTION_NAME| ( <+argument list+> ) +{ +<SPLIT> return <+return value+>; +} /* ----- end of function |FUNCTION_NAME| ----- */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.function-static == +/* + * === FUNCTION ====================================================================== + * Name: |?FUNCTION_NAME| + * Description: + * ===================================================================================== + */ +static void<CURSOR> +|FUNCTION_NAME| ( <+argument list+> ) +{ +<SPLIT> return <+return value+>; +} /* ----- end of static function |FUNCTION_NAME| ----- */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.main == +#include <stdlib.h> + +/* + * === FUNCTION ====================================================================== + * Name: main + * Description: + * ===================================================================================== + */ +int +main ( int argc, char *argv[] ) +{<CURSOR> +<SPLIT> return EXIT_SUCCESS; +} /* ---------- end of function main ---------- */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.enum == +enum |?ENUM_NAME| {<CURSOR> +<SPLIT>}; /* ---------- end of enum |ENUM_NAME| ---------- */ + +typedef enum |ENUM_NAME| |ENUM_NAME:c|; +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.struct == +struct |?STRUCT_NAME| {<CURSOR> +<SPLIT>}; /* ---------- end of struct |STRUCT_NAME| ---------- */ + +typedef struct |STRUCT_NAME| |STRUCT_NAME:c|; +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.union == +union |?UNION_NAME| {<CURSOR> +<SPLIT>}; /* ---------- end of union |UNION_NAME| ---------- */ + +typedef union |UNION_NAME| |UNION_NAME:c|; +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.printf == insert == +printf ( "<CURSOR>\n" ); +== idioms.scanf == insert == +scanf ( "<CURSOR>", & ); +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.calloc == +|?POINTER| = calloc ( (size_t)(<CURSOR><+COUNT+>), sizeof(<+TYPE+>) ); +if ( |POINTER|==NULL ) { + fprintf ( stderr, "\ndynamic memory allocation failed\n" ); + exit (EXIT_FAILURE); +} + +free (|POINTER|); +|POINTER| = NULL; + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.malloc == +|?POINTER| = malloc ( sizeof(<CURSOR><+TYPE+>) ); +if ( |POINTER|==NULL ) { + fprintf ( stderr, "\ndynamic memory allocation failed\n" ); + exit (EXIT_FAILURE); +} + +free (|POINTER|); +|POINTER| = NULL; + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.sizeof == insert == +sizeof(<CURSOR><SPLIT>) +== idioms.assert == insert == +assert(<CURSOR><SPLIT>); +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.open-input-file == +FILE *|?FILEPOINTER|; /* input-file pointer */ +char *|FILEPOINTER|_file_name = "<CURSOR>"; /* input-file name */ + +|FILEPOINTER| = fopen( |FILEPOINTER|_file_name, "r" ); +if ( |FILEPOINTER| == NULL ) { + fprintf ( stderr, "couldn't open file '%s'; %s\n", + |FILEPOINTER|_file_name, strerror(errno) ); + exit (EXIT_FAILURE); +} +<SPLIT>{-continue here-} +if( fclose(|FILEPOINTER|) == EOF ) { /* close input file */ + fprintf ( stderr, "couldn't close file '%s'; %s\n", + |FILEPOINTER|_file_name, strerror(errno) ); + exit (EXIT_FAILURE); +} + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.open-output-file == +FILE *|?FILEPOINTER|; /* output-file pointer */ +char *|FILEPOINTER|_file_name = "<CURSOR>"; /* output-file name */ + +|FILEPOINTER| = fopen( |FILEPOINTER|_file_name, "w" ); +if ( |FILEPOINTER| == NULL ) { + fprintf ( stderr, "couldn't open file '%s'; %s\n", + |FILEPOINTER|_file_name, strerror(errno) ); + exit (EXIT_FAILURE); +} +<SPLIT>{-continue here-} +if( fclose(|FILEPOINTER|) == EOF ) { /* close output file */ + fprintf ( stderr, "couldn't close file '%s'; %s\n", + |FILEPOINTER|_file_name, strerror(errno) ); + exit (EXIT_FAILURE); +} + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.fprintf == insert == +fprintf ( |?FILEPOINTER|, "<CURSOR>\n", ); +== idioms.fscanf == insert == +fscanf ( |?FILEPOINTER|, "<CURSOR>", & ); +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/.vim/c-support/templates/c.preprocessor.template b/.vim/c-support/templates/c.preprocessor.template new file mode 100644 index 0000000..f3aa127 --- /dev/null +++ b/.vim/c-support/templates/c.preprocessor.template @@ -0,0 +1,49 @@ +$------------------------------------------------------------------------- +== preprocessor.include-global == +#include <<CURSOR>> +$------------------------------------------------------------------------- +== preprocessor.include-local == +#include "<CURSOR>" +$------------------------------------------------------------------------- +== preprocessor.define == +#define <CURSOR> /* */ +$------------------------------------------------------------------------- +== preprocessor.undefine == +#undef <CURSOR> /* */ +$------------------------------------------------------------------------- +== preprocessor.if-else-endif == +#if |?CONDITION:u| +<CURSOR><SPLIT> +#else /* ----- not |CONDITION| ----- */ +<+ELSE PART+> +#endif /* ----- not |CONDITION| ----- */ +$------------------------------------------------------------------------- +== preprocessor.ifdef-else-endif == +#ifdef |?CONDITION:u| +<CURSOR><SPLIT> +#else /* ----- not |CONDITION| ----- */ +<+ELSE PART+> +#endif /* ----- not |CONDITION| ----- */ +$------------------------------------------------------------------------- +== preprocessor.ifndef-else-endif == +#ifndef |?CONDITION:u| +<CURSOR><SPLIT> +#else /* ----- not |CONDITION| ----- */ +<+ELSE PART+> +#endif /* ----- not |CONDITION| ----- */ +$------------------------------------------------------------------------- +== preprocessor.ifndef-def-endif == +#ifndef |?BASENAME:L|_INC +#define |BASENAME|_INC +<CURSOR><SPLIT> +#endif /* ----- #ifndef |BASENAME|_INC ----- */ +$------------------------------------------------------------------------- +== preprocessor.error == +#error "<CURSOR>" /* */ +$------------------------------------------------------------------------- +== preprocessor.line == +#line <CURSOR> /* */ +$------------------------------------------------------------------------- +== preprocessor.pragma == +#pragma <CURSOR> /* */ +$------------------------------------------------------------------------- diff --git a/.vim/c-support/templates/c.statements.template b/.vim/c-support/templates/c.statements.template new file mode 100644 index 0000000..574366d --- /dev/null +++ b/.vim/c-support/templates/c.statements.template @@ -0,0 +1,69 @@ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.do-while == +do { +<SPLIT>} while ( <CURSOR> ); /* ----- end do-while ----- */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.for == +for ( <CURSOR>; ; ) +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.for-block == +for ( <CURSOR>; ; ) { +<SPLIT>} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.if == +if ( <CURSOR> ) +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.if-block == +if ( <CURSOR> ) { +<SPLIT><-IF PART-> +} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.if-else == +if ( <CURSOR> ) +<SPLIT>else +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.if-block-else == +if ( <CURSOR> ) { +<SPLIT><-IF PART-> +} +else { +<-ELSE PART-> +} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.else-block == +else { +<CURSOR><SPLIT> +} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.while == +while ( <CURSOR> ) +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.while-block == +while ( <CURSOR> ) { +<SPLIT>} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.switch == +switch ( <CURSOR> ) { + case <-LABEL->: + <SPLIT>break; + + case <-LABEL->: + break; + + case <-LABEL->: + break; + + default: + break; +} /* ----- end switch ----- */ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.case == +case <CURSOR>: +break; + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.block == +{ +<CURSOR><SPLIT> +} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/.vim/c-support/templates/cpp.comments.template b/.vim/c-support/templates/cpp.comments.template new file mode 100644 index 0000000..b91ed44 --- /dev/null +++ b/.vim/c-support/templates/cpp.comments.template @@ -0,0 +1,168 @@ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.end-of-line-comment == append == +// <CURSOR> +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.frame == +//---------------------------------------------------------------------- +// <CURSOR> +//---------------------------------------------------------------------- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.function == +// === FUNCTION ====================================================================== +// Name: |?FUNCTION_NAME| +// Description: <CURSOR> +// ===================================================================================== +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.method == +//-------------------------------------------------------------------------------------- +// Class: |?CLASSNAME| +// Method: |?METHODNAME| +// Description: <CURSOR> +//-------------------------------------------------------------------------------------- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.class == +// ===================================================================================== +// Class: |?CLASSNAME| +// Description: <CURSOR> +// ===================================================================================== +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-description == start == +// ===================================================================================== +// +// Filename: |FILENAME| +// +// Description: <CURSOR> +// +// Version: 1.0 +// Created: |DATE| |TIME| +// Revision: none +// Compiler: g++ +// +// Author: |AUTHOR| (|AUTHORREF|), |EMAIL| +// Company: |COMPANY| +// +// ===================================================================================== +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-description-header == start == +// ===================================================================================== +// +// Filename: |FILENAME| +// +// Description: <CURSOR> +// +// Version: 1.0 +// Created: |DATE| |TIME| +// Revision: none +// Compiler: g++ +// +// Author: |AUTHOR| (|AUTHORREF|), |EMAIL| +// Company: |COMPANY| +// +// ===================================================================================== +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-header-includes == +// ##### HEADER FILE INCLUDES ################################################### + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-macros == +// ##### MACROS - LOCAL TO THIS SOURCE FILE ################################### + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-typedefs == +// ##### TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE ######################### + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-data-types == +// ##### DATA TYPES - LOCAL TO THIS SOURCE FILE ############################### + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-class-defs == +// ##### CLASS DEFINITIONS - LOCAL TO THIS SOURCE FILE ######################## + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-local-variables == +// ##### VARIABLES - LOCAL TO THIS SOURCE FILE ################################ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-prototypes == +// ##### PROTOTYPES - LOCAL TO THIS SOURCE FILE ############################### + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-function-defs-exported == +// ##### FUNCTION DEFINITIONS - EXPORTED FUNCTIONS ############################ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-function-defs-local == +// ##### FUNCTION DEFINITIONS - LOCAL TO THIS SOURCE FILE ##################### + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-class-implementations-exported == +// ##### CLASS IMPLEMENTATIONS - EXPORTED CLASSES ############################# + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-cpp-class-implementations-local == +// ##### CLASS IMPLEMENTATIONS - LOCAL CLASSES ################################ + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-header-includes == +// ##### HEADER FILE INCLUDES ################################################### + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-macros == +// ##### EXPORTED MACROS ######################################################## + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-exported-typedefs == +// ##### EXPORTED TYPE DEFINITIONS ############################################## + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-exported-data-types == +// ##### EXPORTED DATA TYPES #################################################### + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-exported-class-defs == +// ##### EXPORTED CLASS DEFINITIONS ############################################# + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-exported-variables == +// ##### EXPORTED VARIABLES ##################################################### + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.file-section-hpp-exported-function-declarations == +// ##### EXPORTED FUNCTION DECLARATIONS ######################################### + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.keyword-bug == append == + // :BUG:|DATE| |TIME|:|AUTHORREF|: <CURSOR> +== comment.keyword-compiler == append == + // :COMPILER:|DATE| |TIME|:|AUTHORREF|: <CURSOR> +== comment.keyword-todo == append == + // :TODO:|DATE| |TIME|:|AUTHORREF|: <CURSOR> +== comment.keyword-tricky == append == + // :TRICKY:|DATE| |TIME|:|AUTHORREF|: <CURSOR> +== comment.keyword-warning == append == + // :WARNING:|DATE| |TIME|:|AUTHORREF|: <CURSOR> +== comment.keyword-workaround == append == + // :WORKAROUND:|DATE| |TIME|:|AUTHORREF|: <CURSOR> +== comment.keyword-keyword == append == + // :|?KEYWORD:u|:|DATE| |TIME|:|AUTHORREF|: <CURSOR> +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== comment.special-empty == append == + // EMPTY<CURSOR> +== comment.special-fall-through == append == + // FALL THROUGH<CURSOR> +== comment.special-implicit-type-conversion == append == + // IMPLICIT TYPE CONVERSION<CURSOR> +== comment.special-no-return == append == + // NO RETURN<CURSOR> +== comment.special-not-reached == append == + // NOT REACHED<CURSOR> +== comment.special-remains-to-be-implemented == append == + // REMAINS TO BE IMPLEMENTED<CURSOR> +== comment.special-constant-type-is-long == append == + // constant type is long<CURSOR> +== comment.special-constant-type-is-unsigned == append == + // constant type is unsigned<CURSOR> +== comment.special-constant-type-is-unsigned-long == append == + // constant type is unsigned long<CURSOR> +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/.vim/c-support/templates/cpp.cpp.template b/.vim/c-support/templates/cpp.cpp.template new file mode 100644 index 0000000..6bdbe8b --- /dev/null +++ b/.vim/c-support/templates/cpp.cpp.template @@ -0,0 +1,450 @@ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +$ +== cpp.cin == +cin >> <CURSOR>; +$ +== cpp.cout == +cout << <CURSOR> << endl; +$ +== cpp.cout-operator == insert == +<< "<CURSOR>" +$ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.output-manipulator-boolalpha == insert == +<< boolalpha <CURSOR> +== cpp.output-manipulator-dec == insert == +<< dec <CURSOR> +== cpp.output-manipulator-endl == insert == +<< endl <CURSOR> +== cpp.output-manipulator-fixed == insert == +<< fixed <CURSOR> +== cpp.output-manipulator-flush == insert == +<< flush <CURSOR> +== cpp.output-manipulator-hex == insert == +<< hex <CURSOR> +== cpp.output-manipulator-internal == insert == +<< internal <CURSOR> +== cpp.output-manipulator-left == insert == +<< left <CURSOR> +== cpp.output-manipulator-oct == insert == +<< oct <CURSOR> +== cpp.output-manipulator-right == insert == +<< right <CURSOR> +== cpp.output-manipulator-scientific == insert == +<< scientific <CURSOR> +== cpp.output-manipulator-setbase == insert == +<< setbase(10<CURSOR>) +== cpp.output-manipulator-setfill == insert == +<< setfill(<CURSOR>) +== cpp.output-manipulator-setiosflag == insert == +<< setiosflags(<CURSOR>) +== cpp.output-manipulator-setprecision == insert == +<< setprecision(6<CURSOR>) +== cpp.output-manipulator-setw == insert == +<< setw(0<CURSOR>) +== cpp.output-manipulator-showbase == insert == +<< showbase <CURSOR> +== cpp.output-manipulator-showpoint == insert == +<< showpoint <CURSOR> +== cpp.output-manipulator-showpos == insert == +<< showpos <CURSOR> +== cpp.output-manipulator-uppercase == insert == +<< uppercase <CURSOR> +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.method-implementation == +void<CURSOR> +|?CLASSNAME|::|?METHODNAME| ( <+argument list+> ) +{ + return ; +} // ----- end of method |CLASSNAME|::|METHODNAME| ----- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.accessor-implementation == +//-------------------------------------------------------------------------------------- +// Class: |?CLASSNAME| +// Method: get_|?ATTRIBUTE| +//-------------------------------------------------------------------------------------- +inline int<CURSOR> +|CLASSNAME|::get_|ATTRIBUTE| ( ) +{ + return |ATTRIBUTE|; +} // ----- end of method |CLASSNAME|::get_|ATTRIBUTE| ----- + +//-------------------------------------------------------------------------------------- +// Class: |CLASSNAME| +// Method: set_|ATTRIBUTE| +//-------------------------------------------------------------------------------------- +inline void +|CLASSNAME|::set_|ATTRIBUTE| ( <+argument list+> ) +{ + |ATTRIBUTE| = value; + return ; +} // ----- end of method |CLASSNAME|::set_|ATTRIBUTE| ----- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.class-definition == +// ===================================================================================== +// Class: |?CLASSNAME:c| +// Description: <CURSOR> +// ===================================================================================== +class |CLASSNAME| +{ + public: + + // ==================== LIFECYCLE ======================================= + |CLASSNAME| (); // constructor + + // ==================== ACCESSORS ======================================= + + // ==================== MUTATORS ======================================= + + // ==================== OPERATORS ======================================= + + protected: + // ==================== DATA MEMBERS ======================================= + + private: + // ==================== DATA MEMBERS ======================================= + +}; // ----- end of class |CLASSNAME| ----- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.class-implementation == +//-------------------------------------------------------------------------------------- +// Class: |?CLASSNAME| +// Method: |CLASSNAME| +// Description: constructor +//-------------------------------------------------------------------------------------- +|CLASSNAME|::|CLASSNAME| () +{<CURSOR> +} // ----- end of method |CLASSNAME|::|CLASSNAME| (constructor) ----- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.class-using-new-definition == +// ===================================================================================== +// Class: |?CLASSNAME:c| +// Description: <CURSOR> +// ===================================================================================== +class |CLASSNAME| +{ + public: + + // ==================== LIFECYCLE ======================================= + |CLASSNAME| (); // constructor + |CLASSNAME| ( const |CLASSNAME| &other ); // copy constructor + ~|CLASSNAME| (); // destructor + + // ==================== ACCESSORS ======================================= + + // ==================== MUTATORS ======================================= + + // ==================== OPERATORS ======================================= + + |CLASSNAME|& operator = ( const |CLASSNAME| &other ); // assignment operator + + protected: + // ==================== DATA MEMBERS ======================================= + + private: + // ==================== DATA MEMBERS ======================================= + +}; // ----- end of class |CLASSNAME| ----- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.class-using-new-implementation == +//-------------------------------------------------------------------------------------- +// Class: |?CLASSNAME| +// Method: |CLASSNAME| +// Description: constructor +//-------------------------------------------------------------------------------------- +|CLASSNAME|::|CLASSNAME| () +{<CURSOR> +} // ----- end of method |CLASSNAME|::|CLASSNAME| (constructor) ----- + +//-------------------------------------------------------------------------------------- +// Class: |CLASSNAME| +// Method: |CLASSNAME| +// Description: copy constructor +//-------------------------------------------------------------------------------------- +|CLASSNAME|::|CLASSNAME| ( const |CLASSNAME| &other ) +{ +} // ----- end of method |CLASSNAME|::|CLASSNAME| (copy constructor) ----- + +//-------------------------------------------------------------------------------------- +// Class: |CLASSNAME| +// Method: ~|CLASSNAME| +// Description: destructor +//-------------------------------------------------------------------------------------- +|CLASSNAME|::~|CLASSNAME| () +{ +} // ----- end of method |CLASSNAME|::~|CLASSNAME| (destructor) ----- + +//-------------------------------------------------------------------------------------- +// Class: |CLASSNAME| +// Method: operator = +// Description: assignment operator +//-------------------------------------------------------------------------------------- +|CLASSNAME|& +|CLASSNAME|::operator = ( const |CLASSNAME| &other ) +{ + if ( this != &other ) { + } + return *this; +} // ----- end of method |CLASSNAME|::operator = (assignment operator) ----- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.error-class == +// ===================================================================================== +// Class: |?CLASSNAME:c| +// Description: <CURSOR> +// ===================================================================================== +class |CLASSNAME| +{ + public: |CLASSNAME| ( string msg = "|CLASSNAME|" ):message(msg) { } + virtual ~|CLASSNAME| ( ) { } + virtual string what ( ) const throw ( ) { return message; } + protected: string message; +}; // ---------- end of class |CLASSNAME| ---------- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-method-implementation == +template < class T > +void<CURSOR> |?CLASSNAME|<T>::|?METHODNAME| ( <+argument list+> ) +{ + return ; +} // ----- end of method |CLASSNAME|<T>::|METHODNAME| ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-accessor-implementation == +//-------------------------------------------------------------------------------------- +// Class: |?CLASSNAME| +// Method: get_|?ATTRIBUTE| +//-------------------------------------------------------------------------------------- +template < class T > +inline int<CURSOR> |CLASSNAME|<T>::get_|ATTRIBUTE| ( ) +{ + return |ATTRIBUTE|; +} // ----- end of method |CLASSNAME|<T>::get_|ATTRIBUTE| ----- + +//-------------------------------------------------------------------------------------- +// Class: |CLASSNAME| +// Method: set_|ATTRIBUTE| +//-------------------------------------------------------------------------------------- +template < class T > +inline void |CLASSNAME|<T>::set_|ATTRIBUTE| ( <+argument list+> ) +{ + |ATTRIBUTE| = value; + return ; +} // ----- end of method |CLASSNAME|<T>::set_|ATTRIBUTE| ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-class-definition == +// ===================================================================================== +// Class: |?CLASSNAME:c| +// Description: <CURSOR> +// ===================================================================================== + +template < class T > +class |CLASSNAME| +{ + public: + + // ==================== LIFECYCLE ======================================= + |CLASSNAME| (); // constructor + + // ==================== ACCESSORS ======================================= + + // ==================== MUTATORS ======================================= + + // ==================== OPERATORS ======================================= + + protected: + // ==================== DATA MEMBERS ======================================= + + private: + // ==================== DATA MEMBERS ======================================= + +}; // ----- end of template class |CLASSNAME| ----- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-class-implementation == +//-------------------------------------------------------------------------------------- +// Class: |?CLASSNAME| +// Method: |CLASSNAME| +// Description: constructor +//-------------------------------------------------------------------------------------- +template < class T > +|CLASSNAME| <T>:: |CLASSNAME| () +{<CURSOR> +} // ----- end of constructor of template class |CLASSNAME| ----- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-class-using-new-definition == +// ===================================================================================== +// Class: |?CLASSNAME:c| +// Description: <CURSOR> +// ===================================================================================== + +template < class T > +class |CLASSNAME| +{ + public: + + // ==================== LIFECYCLE ======================================= + |CLASSNAME| (); // constructor + |CLASSNAME| ( const |CLASSNAME| &other ); // copy constructor + ~|CLASSNAME| (); // destructor + + // ==================== ACCESSORS ======================================= + + // ==================== MUTATORS ======================================= + + // ==================== OPERATORS ======================================= + + |CLASSNAME|& operator = ( const |CLASSNAME| &other ); // assignment operator + + protected: + // ==================== DATA MEMBERS ======================================= + + private: + // ==================== DATA MEMBERS ======================================= + +}; // ----- end of template class |CLASSNAME| ----- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-class-using-new-implementation == +//-------------------------------------------------------------------------------------- +// Class: |?CLASSNAME| +// Method: |CLASSNAME| +// Description: constructor +//-------------------------------------------------------------------------------------- +template < class T > +|CLASSNAME|<T>::|CLASSNAME| () +{ +} // ----- end of constructor of template class |CLASSNAME| ----- + +//-------------------------------------------------------------------------------------- +// Class: |CLASSNAME| +// Method: |CLASSNAME| +// Description: copy constructor +//-------------------------------------------------------------------------------------- +template < class T > +|CLASSNAME|<T>::|CLASSNAME| ( const |CLASSNAME| &other ) +{<CURSOR> +} // ----- end of copy constructor of template class |CLASSNAME| ----- + +//-------------------------------------------------------------------------------------- +// Class: |CLASSNAME| +// Method: ~|CLASSNAME| +// Description: destructor +//-------------------------------------------------------------------------------------- +template < class T > +|CLASSNAME|<T>::~|CLASSNAME| () +{ +} // ----- end of destructor of template class |CLASSNAME| ----- + +//-------------------------------------------------------------------------------------- +// Class: |CLASSNAME| +// Method: operator = +// Description: assignment operator +//-------------------------------------------------------------------------------------- +template < class T > +|CLASSNAME|<T>& |CLASSNAME|<T>::operator = ( const |CLASSNAME| &other ) +{ + if ( this != &other ) { + } + return *this; +} // ----- end of assignment operator of template class |CLASSNAME| ----- + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.template-function == +template <class T> +void<CURSOR> |?TEMPALTE_FUNCTION_NAME| ( <+argument list+> ) +{ + return ; +} // ----- end of template function |?TEMPALTE_FUNCTION_NAME| ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.operator-in == +ostream & +operator << ( ostream & os, const |?CLASSNAME| & obj ) +{ + os << obj.<CURSOR> ; + return os; +} // ----- end of function operator << ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.operator-out == +istream & +operator >> ( istream & is, |?CLASSNAME| & obj ) +{ + is >> obj.<CURSOR> ; + return is; +} // ----- end of function operator >> ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.try-catch == +try { +<SPLIT>} +catch ( const <CURSOR> &ExceptObj ) { // handle exception: +} +catch (...) { // handle exception: unspecified +} + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.catch == +catch ( <CURSOR>const &ExceptObj ) { // handle exception: +<SPLIT>} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.catch-points == +catch (...) { // handle exception: +<SPLIT>} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.extern == +extern "C" {<CURSOR> +<SPLIT>} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.open-input-file == +string ifs_file_name = "<CURSOR>"; // input file name +ifstream ifs; // create ifstream object + +ifs.open ( ifs_file_name.c_str() ); // open ifstream +if (!ifs) { + cerr << "\nERROR : failed to open input file " << ifs_file_name << endl; + exit (EXIT_FAILURE); +} +<SPLIT>{-continue here-} +ifs.close (); // close ifstream +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.open-output-file == +string ofs_file_name = "<CURSOR>"; // input file name +ofstream ofs; // create ofstream object + +ofs.open ( ofs_file_name.c_str() ); // open ofstream +if (!ofs) { + cerr << "\nERROR : failed to open output file " << ofs_file_name << endl; + exit (EXIT_FAILURE); +} +<SPLIT>{-continue here-} +ofs.close (); // close ofstream +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.namespace-std == +using namespace std; +== cpp.namespace == +using namespace |?NAMESPACE|; +== cpp.namespace-block == +namespace |?NAMESPACE| {<CURSOR> +<SPLIT>} // ----- end of namespace |NAMESPACE| ----- +== cpp.namespace-alias == +namespace |?NAMESPACE_ALIAS| = {-original namespace name-}; +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== cpp.rtti-typeid == insert == +typeid(<CURSOR><SPLIT>) +$ +== cpp.rtti-static-cast == insert == +static_cast<>(<CURSOR><SPLIT>) +$ +== cpp.rtti-const-cast == insert == +const_cast<>(<CURSOR><SPLIT>) +$ +== cpp.rtti-reinterpret-cast == insert == +reinterpret_cast<>(<CURSOR><SPLIT>) +$ +== cpp.rtti-dynamic-cast == insert == +dynamic_cast<>(<CURSOR><SPLIT>) +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/.vim/c-support/templates/cpp.idioms.template b/.vim/c-support/templates/cpp.idioms.template new file mode 100644 index 0000000..fa09ba8 --- /dev/null +++ b/.vim/c-support/templates/cpp.idioms.template @@ -0,0 +1,109 @@ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.function == +void<CURSOR> +|?FUNCTION_NAME| ( <+argument list+> ) +{ +<SPLIT> return <+return value+>; +} // ----- end of function |FUNCTION_NAME| ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.function-static == +static void<CURSOR> +|?FUNCTION_NAME| ( <+argument list+> ) +{ +<SPLIT> return <+return value+>; +} // ----- end of static function |FUNCTION_NAME| ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.main == +#include <cstdlib> + +int +main ( int argc, char *argv[] ) +{<CURSOR> +<SPLIT> return EXIT_SUCCESS; +} // ---------- end of function main ---------- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.enum == +enum |?ENUM_NAME| {<CURSOR> +<SPLIT>}; // ---------- end of enum |ENUM_NAME| ---------- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.struct == +struct |?STRUCT_NAME| {<CURSOR> +<SPLIT>}; // ---------- end of struct |STRUCT_NAME| ---------- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.union == +union |?UNION_NAME| {<CURSOR> +<SPLIT>}; // ---------- end of union |UNION_NAME| ---------- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.printf == insert == +printf ( "<CURSOR>\n" ); +== idioms.scanf == insert == +scanf ( "<CURSOR>", & ); +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.calloc == +|?POINTER| = calloc ( (size_t)(<CURSOR><+COUNT+>), sizeof(<+TYPE+>) ); +if ( |POINTER|==NULL ) { + fprintf ( stderr, "\ndynamic memory allocation failed\n" ); + exit (EXIT_FAILURE); +} + +free (|POINTER|); +|POINTER| = NULL; + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.malloc == +|?POINTER| = malloc ( sizeof(<CURSOR><+TYPE+>) ); +if ( |POINTER|==NULL ) { + fprintf ( stderr, "\ndynamic memory allocation failed\n" ); + exit (EXIT_FAILURE); +} + +free (|POINTER|); +|POINTER| = NULL; + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.sizeof == insert == +sizeof(<CURSOR><SPLIT>) +== idioms.assert == insert == +assert(<CURSOR><SPLIT>); +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.open-input-file == +FILE *|?FILEPOINTER|; // input-file pointer +char *|FILEPOINTER|_file_name = "<CURSOR>"; // input-file name + +|FILEPOINTER| = fopen( |FILEPOINTER|_file_name, "r" ); +if ( |FILEPOINTER| == NULL ) { + fprintf ( stderr, "couldn't open file '%s'; %s\n", + |FILEPOINTER|_file_name, strerror(errno) ); + exit (EXIT_FAILURE); +} +<SPLIT>{-continue here-} +if( fclose(|FILEPOINTER|) == EOF ) { // close input file + fprintf ( stderr, "couldn't close file '%s'; %s\n", + |FILEPOINTER|_file_name, strerror(errno) ); + exit (EXIT_FAILURE); +} + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.open-output-file == +FILE *|?FILEPOINTER|; // output-file pointer +char *|FILEPOINTER|_file_name = "<CURSOR>"; // output-file name + +|FILEPOINTER| = fopen( |FILEPOINTER|_file_name, "w" ); +if ( |FILEPOINTER| == NULL ) { + fprintf ( stderr, "couldn't open file '%s'; %s\n", + |FILEPOINTER|_file_name, strerror(errno) ); + exit (EXIT_FAILURE); +} +<SPLIT>{-continue here-} +if( fclose(|FILEPOINTER|) == EOF ) { // close output file + fprintf ( stderr, "couldn't close file '%s'; %s\n", + |FILEPOINTER|_file_name, strerror(errno) ); + exit (EXIT_FAILURE); +} + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== idioms.fprintf == insert == +fprintf ( |?FILEPOINTER|, "<CURSOR>\n", ); +== idioms.fscanf == insert == +fscanf ( |?FILEPOINTER|, "<CURSOR>", & ); +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/.vim/c-support/templates/cpp.preprocessor.template b/.vim/c-support/templates/cpp.preprocessor.template new file mode 100644 index 0000000..68de87f --- /dev/null +++ b/.vim/c-support/templates/cpp.preprocessor.template @@ -0,0 +1,50 @@ +$------------------------------------------------------------------------- +== preprocessor.include-global == +#include <<CURSOR>> +$------------------------------------------------------------------------- +== preprocessor.include-local == +#include "<CURSOR>" +$------------------------------------------------------------------------- +== preprocessor.define == +#define <CURSOR> // +$------------------------------------------------------------------------- +== preprocessor.undefine == +#undef <CURSOR> // +$------------------------------------------------------------------------- +== preprocessor.if-else-endif == +#if |?CONDITION:u| +<CURSOR><SPLIT> +#else // ----- not |CONDITION| ----- +<+ELSE PART+> + +#endif // ----- not |CONDITION| ----- +$------------------------------------------------------------------------- +== preprocessor.ifdef-else-endif == +#ifdef |?CONDITION:u| +<CURSOR><SPLIT> +#else // ----- not |CONDITION| ----- +<+ELSE PART+> +#endif // ----- not |CONDITION| ----- +$------------------------------------------------------------------------- +== preprocessor.ifndef-else-endif == +#ifndef |?CONDITION:u| +<CURSOR><SPLIT> +#else // ----- not |CONDITION| ----- +<+ELSE PART+> +#endif // ----- not |CONDITION| ----- +$------------------------------------------------------------------------- +== preprocessor.ifndef-def-endif == +#ifndef |?BASENAME:L|_INC +#define |BASENAME|_INC +<CURSOR><SPLIT> +#endif // ----- #ifndef |BASENAME|_INC ----- +$------------------------------------------------------------------------- +== preprocessor.error == +#error "<CURSOR>" // +$------------------------------------------------------------------------- +== preprocessor.line == +#line <CURSOR> // +$------------------------------------------------------------------------- +== preprocessor.pragma == +#pragma <CURSOR> // +$------------------------------------------------------------------------- diff --git a/.vim/c-support/templates/cpp.statements.template b/.vim/c-support/templates/cpp.statements.template new file mode 100644 index 0000000..c2fdecb --- /dev/null +++ b/.vim/c-support/templates/cpp.statements.template @@ -0,0 +1,72 @@ +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.do-while == +do { +<SPLIT>} while ( <CURSOR> ); // ----- end do-while ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.for == +for ( <CURSOR>; ; ) +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.for-block == +for ( <CURSOR>; ; ) { +<SPLIT>} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.if == +if ( <CURSOR> ) +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.if-block == +if ( <CURSOR> ) { +<SPLIT><-IF PART-> +} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.if-else == +if ( <CURSOR> ) +<SPLIT>else +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.if-block-else == +if ( <CURSOR> ) { +<SPLIT><-IF PART-> +} +else { +<+ELSE PART+> +} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.else-block == +else { +<CURSOR><SPLIT> +} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.while == +while ( <CURSOR> ) +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.while-block == +while ( <CURSOR> ) { +<SPLIT>} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.switch == +switch ( <CURSOR> ) { + case 1: + <SPLIT>break; + + case 2: + break; + + case 3: + break; + + case 4: + break; + + default: + break; +} // ----- end switch ----- +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.case == +case <CURSOR>: +break; + +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== statements.block == +{ +<CURSOR><SPLIT> +} +$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/.vim/c-support/wordlists/c-c++-keywords.list b/.vim/c-support/wordlists/c-c++-keywords.list new file mode 100644 index 0000000..5a97dd6 --- /dev/null +++ b/.vim/c-support/wordlists/c-c++-keywords.list @@ -0,0 +1,209 @@ +adjustfield +basefield +boolalpha +floatfield +internal +scientific +setbase +setiosflags +setprecision +showbase +showpoint +showpos +uppercase + +auto +break +case +char +const +continue +default +double +else +enum +extern +float +goto +inline +long +register +restrict +return +short +signed +sizeof +static +struct +switch +typedef +union +unsigned +void +volatile +while +_Bool +_Complex +_Imaginary +EXIT_FAILURE +EXIT_SUCCESS + +bool +catch +class +const_cast +delete +dynamic_cast +explicit +export +false +friend +mutable +namespace +operator +private +protected +public +reinterpret_cast +static_cast +template +this +throw +true +typeid +typename +using +virtual +wchar_t + +and_eq +bitand +bitor +compl +not_eq +or_eq +xor_eq + +define +defined +elif +endif +error +ifdef +ifndef +include +pragma +undef + +exception +bad_alloc +bad_exception +bad_cast +bad_typeid +ios_base::failure +logic_error +domain_error +invalid_argument +length_error +out_of_range +runtime_error +range_error +overflow_error +underflow_error +uncaught_exception + +__DATE__ +__FILE__ +__LINE__ +__STDC__ +__STDC_HOSTED__ +__STDC_IEC_559__ +__STDC_IEC_559_COMPLEX__ +__STDC_ISO_10646__ +__STDC_VERSION__ +__TIME__ +__func__ +__cplusplus + +__BORLANDC__ +__CYGWIN__ +__CYGWIN32__ +__GNUC__ +__WIN32__ +__WINDOWS__ + +assert +ctype +errno +float +limits +locale +math +setjmp +signal +stdarg +stddef +stdio +stdlib +string +time + +complex +fenv +inttypes +iso646 +stdbool +stdint +tgmath +wchar +wctype + +algorithm +bitset +complex +deque +exception +fstream +functional +iomanip +ios +iosfwd +iostream +istream +iterator +limits +list +locale + +map +memory +new +numeric +ostream +queue +set +sstream +stack +stdexcept +streambuf +string +typeinfo +utility +valarray +vector + +cassert +cctype +cerrno +cfloat +climits +clocale +cmath +csetjmp +csignal +cstdarg +cstddef +cstdio +cstdlib +cstring +ctime diff --git a/.vim/c-support/wordlists/k+r.list b/.vim/c-support/wordlists/k+r.list new file mode 100644 index 0000000..805756a --- /dev/null +++ b/.vim/c-support/wordlists/k+r.list @@ -0,0 +1,108 @@ +address +allocator +allocation +argument +arithmetic +array +assignement +bitwise +block +character +command +condition +conditional +constant +conversion +declaration +decrement +defined +definition +descriptor +description +dimension +evaluation +expression +external +format +formatted +function +global +handling +identifier +implementation +increment +initialization +input +interface +label +lexical +local +logical +lookup +loop +lvalue +miscellaneous +notation +numerical +operator +operation +output +pointer +precedence +preprocessor +preprocessing +program +random +recursion +recursive +reference +referential +relational +scope +standard +statement +string +structure +system +undefined +variable + +abstract +algorithm +alignment +application +assignment +asynchronous +binary +buffer +component +constructor +container +destructor +difference +enumeration +exception +floating-point +horizontal +inheritance +instantiation +integer +internal +invariant +iterator +localization +overflow +overload +override +overwrite +polymorphic +portability +position +postcondition +precision +precondition +prototype +subscript +underflow +vertical +whitespace diff --git a/.vim/c-support/wordlists/stl_index.list b/.vim/c-support/wordlists/stl_index.list new file mode 100644 index 0000000..b5d98a3 --- /dev/null +++ b/.vim/c-support/wordlists/stl_index.list @@ -0,0 +1,202 @@ +accumulate +adjacent_difference +adjacent_find +advance +append +assign +auto_ptr +back +back_inserter +basic_string +bidirectional_iterator +bidirectional_iterator_tag +binary_compose +binary_function +binary_negate +binary_search +bind1st +bind2nd +bit_vector +bitset +capacity +char_producer +char_traits +char_type +compare +construct +copy +copy_backward +copy_n +count +count_if +deque +destroy +distance +distance_type +divides +equal +equal_range +equal_to +erase +fill +fill_n +find +find_end +find_first_not_of +find_first_of +find_if +find_last_not_of +find_last_of +for_each +forward_iterator +forward_iterator_tag +front +front_inserter +generate +generate_n +get_temporary_buffer +greater +greater_equal +hash +hash_map +hash_multimap +hash_multiset +hash_set +identity +includes +inner_product +inplace_merge +input_iterator +input_iterator_tag +insert +insert_iterator +inserter +int_type +iota +is_heap +is_sorted +istream_iterator +istream_type +istreambuf_iterator +iter_swap +iterator_category +iterator_traits +less +less_equal +lexicographical_compare +lexicographical_compare_3way +list +logical_and +logical_not +logical_or +lower_bound +make_heap +make_pair +map +max +max_element +mem_fun1_ref_t +mem_fun1_t +mem_fun_ref_t +mem_fun_t +merge +min +min_element +minus +mismatch +modulus +multimap +multiplies +multiset +negate +next_permutation +not_equal_to +nth_element +operator +ostream_iterator +ostreambuf_iterator +output_iterator +output_iterator_tag +pair +partial_sort +partial_sort_copy +partial_sum +partition +plus +pointer_to_binary_function +pointer_to_unary_function +pop_back +pop_front +pop_heap +power +prev_permutation +priority_queue +project1st +project2nd +ptr_fun +push_back +push_front +push_heap +queue +random_access_iterator +random_access_iterator_tag +random_sample +random_sample_n +random_shuffle +raw_storage_iterator +release +remove +remove_copy +remove_copy_if +remove_if +replace +replace_copy +replace_copy_if +replace_if +reset +resize +return_temporary_buffer +reverse +reverse_bidirectional_iterator +reverse_copy +reverse_iterator +rfind +rope +rotate +rotate_copy +search +search_n +select1st +select2nd +sequence_buffer +set +set_difference +set_intersection +set_symmetric_difference +set_union +slist +sort +sort_heap +stable_partition +stable_sort +stack +streambuf_type +substr +subtractive_rng +swap +swap_ranges +temporary_buffer +transform +unary_compose +unary_function +unary_negate +uninitialized_copy +uninitialized_copy_n +uninitialized_fill +uninitialized_fill_n +unique +unique_copy +upper_bound +value_comp +value_type +vector diff --git a/.vim/doc/cecscope.txt b/.vim/doc/cecscope.txt new file mode 100644 index 0000000..46e7121 --- /dev/null +++ b/.vim/doc/cecscope.txt @@ -0,0 +1,167 @@ +*cecscope.txt* Charles E Campblell's Cscope Plugin Nov 12, 2008 + +Author: Charles E. Campbell, Jr. <NdrOchip@ScampbellPfamily.AbizM> + (remove NOSPAM from Campbell's email first) +Copyright: (c) 2004-2008 by Charles E. Campbell, Jr. *cecscope-copyright* + The VIM LICENSE applies to cecscope.vim and cecscope.txt + (see |copyright|) except use "cecscope" instead of "Vim". + No warranty, express or implied. Use At-Your-Own-Risk. +Note: Required: + * your :version of vim must have +cscope + * vim 7.0aa snapshot#188 or later for the "quickfix" display + +============================================================================== +1. Contents *cecscope-contents* + + 1. Contents............................: |cecscope-contents| + 2. Installing cecscope.................: |cecscope-install| + 3. Cescope Manual......................: |cecscope-manual| + 3. Cescope Tutorial....................: |cecscope-tutorial| + 5. Cescope History.....................: |cecscope-history| + + +============================================================================== +2. Installing cecscope *cecscope-install* + + 1. vim cecscope.vba.gz + 2. :so % + 3. :q + + Cecscope now requires vim 7.2 or later; it uses the fnameescape() function + to avoid certain security problems. It is possible to use "carefully + crafted filenames" to cause vim to execute arbitrary commands otherwise. + Admittedly, most such filenames are obviously bad apples. + + Using vim 7.2 also means that your vimball plugin is reasonably + up-to-date, which is used by the install process. + +============================================================================== +3. Cescope Manual *cecscope-manual* + *:CS* *:CSL* *:CSS* *:CSH* + :CS [cdefgist] : cscope command handler + :CSL[!] [cdefgist] : locallist style (! restores efm) + :CSS[!] [cdefgist] : split window and use cscope + :CSH : give quick help + :CSR : cscope reset + + ! split vertically + c (calls) find functions calling function under cursor + d (called) find functions called by function under cursor + e (egrep) egrep search for the word under cursor + f (file) open the file named under cursor + g (global) find global definition(s) of word under cursor + i (includes) find files that #include file named under cursor + s (symbol) find all references to the word under cursor + t (text) find all instances of the word under cursor + + A simple > + :CS +< will initialize cscope, building its database if necessary. What + :CS will do: > + + if cscope.out exists in the current directory, cs add it. + if $CSCOPE_DB (an environment variable) exists and the + file it references exists, cs add it. + if cscope.out exists in any directory from the current + directory or in any parent directory up to but not + including the $HOME directory, cs add it. + if cscope is executable, apply cscope -b to the current file. +< + Thus :CS will search for and attempt to use a cscope database, + building one if necessary. + + In addition, when using gvim, there is a menu interface under the + "DrChip" label with all of the above options mentioned. The first + four items are taken from: + + Help + Use Messages Display + Use Horiz Split Display + Use Vert Split Display + Use Quickfix Display + + The "Use" method that's currently active will not be present (initially, + that's the "Use Messages Display"). + + *g:cecscope_dboptions* + For special options to be passed to cscope for database building, set + g:cecscope_dboptions to the desired string. For example, to use all + source files in a so-called namefile: > + let g:cecscope_dboptions= "-inamefile" +< One must explicitly list *.cpp, *.c++, and *.C files, for example, in + such a file. + + +============================================================================== +4. Cescope Tutorial *cecscope-tutorial* + + GETTING STARTED + To use this plugin you'll need to have vim 7.0aa, snapshot#188 or later, + and your version should have +cscope. To check that latter condition, + either look for +cscope through the output of > + :version +< or type > + :echo has("cscope") +< You'll need to recompile your vim if you don't have +cscope. + + BUILDING CSCOPE DATABASE + Once you have your cscope-enabled vim, then change directory to wherever + you have some C code. Type > + cscope -b *.[ch] +< and the cscope database will be generated (<cscope.out>). If you don't + have a cscope database, the file specified by the environment variable + named > + $CSCOPE_DB +< will be used. Sadly, otherwise cecscope.vim will issue a warning message. + + SELECTING A DISPLAY MODE + + Assuming you're using gvim: Select > + DrChip:Cscope:Use Quickfix Display +< This will make the information from cscope show up in a local quickfix + window (see |:lopen|). The other modes allow one to see cscope messages + as regular messages (which will shortly disappear) or in another window. + + USING THE QUICKFIX DISPLAY + Place your cursor atop some function that you've written: > + DrChip:Cscope:Find function which calls word under cursor +< and you'll see a locallist window open up which tells you something like > + xgrep.c|410 info| <<sprt>> Edbg(("xgrep(%s)",sprt(filename))); +< To jump to that entry, type > + :ll +< To jump to the next entry, type > + :lne +< To jump to the previous entry, type > + :lp +< You can also switch windows (ex. <ctrl-w>j, see |window-move-cursor|) + to the locallist window, move the cursor about normally, then hit the + <cr> to jump to the selection. + + USING THE COMMAND LINE + You could've done the above using the command line! Again, just + place your cursor atop some function that you've written, then type: > + :CSL c +< You may use the :ll, :lne, and :lp commands as before. + + HELP + Just type > + :CSH +< for a quick help display. Of course, you can always type : > + :help CS +< too. + + +============================================================================== +5. Cescope History *cecscope-history* + + v4 Nov 12, 2008 * csqf kept if has("quickfix") is true + * vim 7.2 required, and warning message is issued if + vim isn't 7.2 (or later) + * fnameescape() used for security purposes (thus vim 7.2) + * help menu fixed + v3 Oct 12, 2006 : removed "silent" from cscope calls; it prevented the + selector from appearing. + v1 Jan 30, 2006 : initial release + +===================================================================== +vim:tw=78:ts=8:ft=help:sts=4:et:ai diff --git a/.vim/doc/crefvim.txt b/.vim/doc/crefvim.txt new file mode 100755 index 0000000..8fea502 --- /dev/null +++ b/.vim/doc/crefvim.txt @@ -0,0 +1,14112 @@ +*crefvim.txt* C-Reference Manual for Vim + Vim version 6.0 + + + *crefvim* *C-Reference* + C-Reference for Vim + ====================== + Version 1.0.3 + 27. Nov. 2004 + + (c) 2002-2004 by Christian Habermann + christian (at) habermann-net (point) de + + + "The GNU C Library Reference Manual" is + copyright (c) 1993 - 2002 by the + Free Software Foundation, Inc. + + + See |crefvimdoc| for further information on the project CRefVim. + See |crvdoc-copyright| for copyright and licenses. + + + Table of C o n t e n t s: + + Introduction..................|crv-intro| + + Chapter I LANGUAGE......................|crv-language| + I.1 Characters..................|crv-lngChar| + I.1.1 Allowed Characters........|crv-lngAllowedChar| + I.1.2 Comment...................|crv-lngComment| + I.1.3 Escape-Sequences..........|crv-lngEscSeq| + + I.2 Keywords....................|crv-keywords| + + I.3 Operators...................|crv-operators| + I.3.1 Overview..................|crv-opOverview| + I.3.2 Arithmetic................|crv-opArithmetic| + I.3.3 Logical...................|crv-opLogical| + I.3.4 Relational................|crv-opRelational| + I.3.5 Bitwise...................|crv-opBitwise| + I.3.6 Assignments...............|crv-opAssigns| + I.3.7 Others....................|crv-opOthers| + I.3.7.1 Size of.................|crv-opSizeOf| + I.3.7.2 Address of..............|crv-opAddress| + I.3.7.3 Contents of.............|crv-opContents| + I.3.7.4 Conditional.............|crv-opConditional| + I.3.7.5 Series..................|crv-opSeries| + I.3.7.6 Type Cast...............|crv-opTypeCast| + I.3.7.7 Struct/Union Selectors..|crv-opStructUnionSel| + I.3.7.8 Array Selector..........|crv-opArraySel| + I.3.7.9 Parentheses.............|crv-opParenth| + I.3.8 Precedence................|crv-opPrecedence| + + I.4 Punctuators.................|crv-punctuators| + + I.5 Datatypes...................|crv-datatypes| + I.5.1 Overview..................|crv-dtOverview| + I.5.1.1 Type Specifiers.........|crv-dtTypeSpecifiers| + I.5.1.2 Type Grouping...........|crv-dtTypeGrouping| + I.5.2 Sizes and Ranges..........|crv-dtSizeRange| + I.5.2 Formats...................|crv-dtFormats| + I.5.2.1 Integer.................|crv-dtFormatsInt| + I.5.2.2 Floating-Point..........|crv-dtFormatsFloat| + I.5.2.2.1 Basics................|crv-dtFormatsFPBasics| + I.5.2.2.2 Types.................|crv-dtFormatsFPTypes| + I.5.3 void Type.................|crv-dtVoid| + I.5.4 Arrays....................|crv-dtArrays| + I.5.5 Structures................|crv-dtStructurs| + I.5.6 Unions....................|crv-dtUnions| + I.5.7 Bit-Fields................|crv-dtBitFields| + I.5.8 Enumerated Tags...........|crv-dtEnumerate| + I.5.9 Strings...................|crv-dtStrings| + I.5.10 Type Definitions..........|crv-dtTypeDef| + I.5.11 Storage Classes...........|crv-dtStorageClasses| + I.5.12 Qualifiers................|crv-dtQualifiers| + I.5.13 Pointers..................|crv-dtPointers| + I.5.13.1 Variables...............|crv-dtPtrVars| + I.5.13.2 Functions...............|crv-dtPtrFuncs| + I.5.13.3 Arithmetics.............|crv-dtPtrArithmetics| + I.5.14 Type Cast.................|crv-dtTypeCast| + I.5.14.1 Explicit................|crv-dtTypeCastExpl| + I.5.14.2 Implicit................|crv-dtTypeCastImpl| + I.5.15 Constants.................|crv-dtConstants| + I.5.15.1 Integer.................|crv-dtConstInt| + I.5.15.2 Floating-Point..........|crv-dtConstFloat| + I.5.15.3 Character...............|crv-dtConstChar| + + I.6 Statements..................|crv-statements| + I.6.1 if-else...................|crv-stIfElse| + I.6.2 switch....................|crv-stSwitch| + I.6.3 while Loop................|crv-stWhile| + I.6.4 do-while Loop.............|crv-stDoWhile| + I.6.5 for Loop..................|crv-stFor| + I.6.6 break.....................|crv-stBreak| + I.6.7 continue..................|crv-stContinue| + I.6.8 goto......................|crv-stGoto| + I.6.9 return....................|crv-stReturn| + I.6.10 Null Statement............|crv-stNull| + + I.7 Functions...................|crv-functions| + I.7.1 Definition................|crv-fuDefinition| + I.7.2 Protoype..................|crv-fuPrototype| + I.7.3 Conversion................|crv-fuConversion| + I.7.4 Storage Classes...........|crv-fuStorageClasses| + I.7.5 Specifier.................|crv-fuSpecifier| + I.7.6 main()....................|crv-fuMain| + + I.8 Preprocessor................|crv-preprocessor| + I.8.1 Macros....................|crv-preMacros| + I.8.1.1 Definition #define......|crv-preMacDef| + I.8.1.2 Cancellation #undef.....|crv-preMacCancel| + I.8.1.3 # Operator..............|crv-preMac#Operator| + I.8.1.4 ## Operator.............|crv-preMac##Operator| + I.8.1.5 Predefined Macros.......|crv-preMacPredefined| + I.8.2 Conditional Compilation...|crv-preConditional| + I.8.2.1 defined Operator........|crv-preCondDefined| + I.8.2.2 #if Directive...........|crv-preCondIf| + I.8.2.3 #ifdef Directive........|crv-preCondIfdef| + I.8.2.4 #ifndef Directive.......|crv-preCondIfndef| + I.8.2.5 #else Directive.........|crv-preCondElse| + I.8.2.6 #elif Directive.........|crv-preCondElif| + I.8.2.7 #endif Directive........|crv-preCondEndif| + I.8.3 File Inclusion #include...|crv-preSourceInc| + I.8.4 Line Control #line........|crv-preLine| + I.8.5 Error Directive #error....|crv-preError| + I.8.6 Pragma Directive #pragma..|crv-prePragma| + I.8.7 Null Directive #..........|crv-preNull| + + + Chapter II STANDARD C LIBRARY............|crv-stdCLib| + II.1 Standard Headers............|crv-libHeaders| + + II.2 <assert.h> Diagnostics......|crv-libAssertH| + + II.3 <complex.h> Complex Math....|crv-libComplexH| + II.3.1 Macros....................|crv-libCHMac| + II.3.2 Pragmas...................|crv-libCHPrag| + II.3.3 Trigonometric.............|crv-libCHTrig| + II.3.4 Hyperbolic................|crv-libCHHyper| + II.3.5 Exponential & Logarithmic.|crv-libCHExpLog| + II.3.6 Power & Absolute..........|crv-libCHPower| + II.3.7 Manipulating..............|crv-libCHMani| + + II.4 <ctype.h> Character.........|crv-libCtypeH| + II.4.1 Character Handling........|crv-libCharHandling| + II.4.2 Character Mapping.........|crv-libCharMapping| + + II.5 <errno.h> Error Codes.......|crv-libErrnoH| + + II.6 <fenv.h> FPU Status.........|crv-libFenvH| + II.6.1 Pragmas...................|crv-libFHPrag| + II.6.2 Exceptions................|crv-libFHExceptions| + II.6.3 Rounding..................|crv-libFHRounding| + II.6.4 Environment...............|crv-libFHEnv| + + II.7 <float.h> Floating Point....|crv-libFloatH| + + II.8 <inttypes.h> Absolute Value.|crv-libInttypesH| + + II.9 <iso646.h> Alternatives.....|crv-libIso646H| + + II.10 <limits.h> Limits of Int....|crv-libLimitsH| + II.10.1 Range of Integer Types....|crv-libLHRange| + II.10.2 Width of Type.............|crv-libLHWidth| + II.10.3 Conversion and Properties.|crv-libLHConv| + + II.11 <local.h> Localization......|crv-libLocalH| + II.11.1 Categories................|crv-libLocHCat| + II.11.2 Standard Locales..........|crv-libLocHLoc| + II.11.3 Information Structure.....|crv-libLocHInfo| + II.11.4 Functions.................|crv-libLocHFunc| + + II.12 <math.h> Mathematics........|crv-libMathH| + II.12.1 Error Conditions..........|crv-libMHErr| + II.12.2 Classification Macros.....|crv-libMHClass| + II.12.3 Comparison Macros.........|crv-libMHCmp| + II.12.4 Trigonometric.............|crv-libMHTrig| + II.12.5 Hyperbolic................|crv-libMHHyper| + II.12.6 Exponential & Logarithmic.|crv-libMHExpLog| + II.12.7 Power & Absolute..........|crv-libMHPower| + II.12.8 Error & Gamma.............|crv-libMHErrGam| + II.12.9 Nearest Integer...........|crv-libMHNear| + II.12.10 Remainder.................|crv-libMHRem| + II.12.11 Manipulating..............|crv-libMHMani| + II.12.12 Miscellaneous.............|crv-libMHMisc| + + II.13 <setjmp.h> Nonlocal Jumps...|crv-libSetjmpH| + + II.14 <signal.h> Signal Handling..|crv-libSignalH| + II.14.1 Types.....................|crv-libSHTyp| + II.14.2 Signals...................|crv-libSHSig| + II.14.3 Functions.................|crv-libSHFunc| + + II.15 <stdarg.h> Arguments........|crv-libStdargH| + + II.16 <stdbool.h> Boolean Type....|crv-libStdboolH| + + II.17 <stddef.h> Definitions......|crv-libStddefH| + + II.18 <stdint.h> Integer Type.....|crv-libStdintH| + II.18.1 Integer Types.............|crv-libSdHType| + II.18.1.1 Exact-Width.............|crv-libSdHTExact| + II.18.1.2 Minimum-Width...........|crv-libSdHTMin| + II.18.1.3 Fastest Minimum-Width...|crv-libSdHTFast| + II.18.1.4 Greatest-Width..........|crv-libSdHTGreat| + II.18.1.5 Hold Pointer............|crv-libSdHTPtr| + II.18.2 Limits....................|crv-libSdHTLim| + II.18.2.1 Exact-Width.............|crv-libSdHLExact| + II.18.2.2 Minimum-Width...........|crv-libSdHLMin| + II.18.2.3 Fastest Minimum-Width...|crv-libSdHLFast| + II.18.2.4 Greatest-Width..........|crv-libSdHLGreat| + II.18.2.5 Others..................|crv-libSdHLOther| + II.18.2.6 Hold Pointer............|crv-libSdHLPtr| + II.18.3 Macros....................|crv-libSdHMac| + + II.19 <stdio.h> Input/Output......|crv-libStdioH| + II.19.1 Types.....................|crv-libSIOHType| + II.19.2 Macros....................|crv-libSIOHMac| + II.19.3 Streams and Files.........|crv-libSIOHStrmFile| + II.19.4 File Operations...........|crv-libSIOHFOp| + II.19.5 File Access...............|crv-libSIOHFAcc| + II.19.6 Formatted Input/Output....|crv-libSIOHIO| + II.19.6.1 Format Control..........|crv-libSIOHIOFormat| + II.19.6.1.1 Output, printf()......|crv-libSIOHIOFout| + II.19.6.1.2 Input, scanf()........|crv-libSIOHIOFin| + II.19.6.2 Functions...............|crv-libSIOHIOFunc| + II.19.7 Character Input/Output....|crv-libSIOHCIO| + II.19.8 Direct Input/Output.......|crv-libSIOHDIO| + II.19.9 File Positioning..........|crv-libSIOHFPos| + II.19.10 Error Handling............|crv-libSIOHErr| + + II.20 <stdlib.h> Utilities........|crv-libStdlibH| + II.20.1 Types.....................|crv-libSLHType| + II.20.2 Macros....................|crv-libSLHMac| + II.20.3 Numeric Conversion........|crv-libSLHnum| + II.20.4 Pseudo-Random.............|crv-libSLHrand| + II.20.5 Memory Management.........|crv-libSLHmem| + II.20.6 Communication.............|crv-libSLHcom| + II.20.7 Searching and Sorting.....|crv-libSLHsearch| + II.20.8 Integer Arithmetic........|crv-libSLHintarith| + II.20.9 Multibyte/Wide Character..|crv-libSLHmulchar| + II.20.10 Multibyte/Wide String.....|crv-libSLHmulstrng| + + II.21 <string.h> String...........|crv-libStringH| + II.21.1 Types.....................|crv-libSRHType| + II.21.2 Macros....................|crv-libSRHMac| + II.21.3 Copying...................|crv-libSRHCopy| + II.21.4 Concatenation.............|crv-libSRHConcat| + II.21.5 Comparison................|crv-libSRHCmp| + II.21.6 Search....................|crv-libSRHSearch| + II.21.7 Miscellaneous.............|crv-libSRHMisc| + + II.22 <tgmath.h> Type-Generic.....|crv-libTgmathH| + + II.23 <time.h> Date and Time......|crv-libTimeH| + II.23.1 Types.....................|crv-libTHType| + II.23.2 Macros....................|crv-libTHMac| + II.23.3 Time Manipulation.........|crv-libTHMani| + II.23.4 Time Conversion...........|crv-libTHConv| + + II.24 <wchar.h> Wide Utilities....|crv-libWcharH| + II.24.1 Types.....................|crv-libWCHType| + II.24.2 Macros....................|crv-libWCHMac| + II.24.3 Formatted Input/Output....|crv-libWCHIO| + II.24.4 Character Input/Output....|crv-libWCHCIO| + II.24.5 String Utilities..........|crv-libWCHStrng| + II.24.5.1 Numeric Conversions.....|crv-libWCHNum| + II.24.5.2 Copying.................|crv-libWCHCopy| + II.24.5.3 Concatenation...........|crv-libWCHConcat| + II.24.5.4 Comparison..............|crv-libWCHCmp| + II.24.5.5 Search..................|crv-libWCHSearch| + II.24.5.6 Miscellaneous...........|crv-libWCHMisc| + II.24.6 Time Conversions..........|crv-libWCHTimeConv| + II.24.7 Character Conversions.....|crv-libWCHCharConv| + + II.25 <wctype.h> Wide Character...|crv-libWctypeH| + II.25.1 Types.....................|crv-libWTHType| + II.25.2 Macros....................|crv-libWTHMac| + II.25.3 Classification............|crv-libWTHClass| + II.25.3.1 Wide Character..........|crv-libWTHCwide| + II.25.3.2 Extensible Wide Char....|crv-libWTHCextens| + II.25.4 Mapping...................|crv-libWTHMap| + II.25.4.1 Wide Character..........|crv-libWTHMwide| + II.25.4.2 Extensible Wide Char....|crv-libWTHMextens| + + + Appendix A GLOSSARY............................|crv-glossary| + B BIBLIOGRAPHY........................|crv-bibliography| + C COPYRIGHT & LICENSES................|crvdoc-copyright| + C.1 GNU General Public License........|crvdoc-licGPL| + C.2 GNU Free Documentation License....|crvdoc-licFDL| + C.3 GNU Lesser General Public License.|crvdoc-licLGPL| + C.4 Free Software Needs Free + Documentation.....................|crvdoc-licFreeDoc| + D AUTHOR..............................|crvdoc-author| + E CREDITS.............................|crvdoc-credits| + F HISTORY.............................|crvdoc-history| + + +Happy viming... + + +============================================================================== +Introduction *crv-intro* +============================================================================== + + +This document is a C-reference manual. It is NOT a tutorial on how to write +C programs. It is simply a quick reference to the standard C programming +language and its standard library functions. +The language description is based on the standard ISO/IEC 9899:1999(E), second +edition. But this reference does not contain all information from this +standard, it tries to reflect only the most important information. + +DISCLAIMER: All efforts have been taken to make sure that all information + in this document is correct, but no guarantee is implied or + intended. + +This C-reference manual is designed to be best viewed with Vim and syntax- +highlighting enabled. Furthermore when using Vim it's possible to navigate +through this document by tags. Vim is a very powerful text-editor available +for close to all platforms. + +This C-reference is divided into two chapters and an appendix. The first +chapter deals mainly with the language. The second chapter shows the +functions of the standard C library. The appendix includes a glossary and +other items of interest. + + + + + +============================================================================== +Chapter I LANGUAGE *crv-language* +============================================================================== + + + +============================================================================== +I.1 Characters *crv-lngChar* + + +------------------------------------------------------------------------------ +I.1.1 Allowed Characters *crv-lngAllowedChar* + +In a C source code the following characters are allowed: + + Digits: 0...9 + Letters: a-z A-Z + Others: ! " # & ' + - * / % , . : ; < = > ? \ ^ _ | ~ + parentheses ( ) + brackets [ ] + braces { } + space, tabulator, form feed + + Trigraphs: ??= # ??) ] ??! | *crv-trigraph* + ??( [ ??' ^ ??> } + ??/ \ ??< { ??- ~ + If a trigraph sequence is found in the source code it is + replaced with the corresponding single character. This allows + to enter some special symbols on platforms not providing these + symbols. + + +------------------------------------------------------------------------------ +I.1.2 Comment *crv-lngComment* + +There are two types of comments: + - block comment $/*...*/$ + - line comment $//$ + +Block Comment: *crv-lngBlockComment* + A block comment starts with $/*$ and ends with $*/$. All characters between + start and end are treated as comment. Nesting is not allowed. + +Line Comment: *crv-lngLineComment* + A line comment starts with $//$ and ends at the next new-line character + (new-line character is not included). + + + +------------------------------------------------------------------------------ +I.1.3 Escape-Sequences *crv-lngEscSeq* + + + Escape Sequence | Name | Meaning + ----------------+-----------------+------------------------------------------ + \' | | single quote ' + \" | | double quote " + \? | | question mark ? + \\ | | backslash \ + | | + \a | Alert | produces an audible or visible alert + \b | Backspace | moves cursor back one position + \f | Form Feed | moves cursor to start of next page + \n | New Line | moves cursor to start of next line + \r | Carriage Return | moves cursor to start of current line + \t | horiz. tabulator| moves cursor to next horiz. tab. position + \v | vert. tabulator | moves cursor to next vert. tab. position + | | + \0octal-digits | | octal character + \xhex-digits | | hexadecimal character + | | + \0 | null character | character with the value 0 + | | + \<cr> | | concatenates actual line with next one + | | (backslash immediately followed by a + | | new-line) + + + +============================================================================== +I.2 Keywords *crv-keywords* + +Keywords are words with a special meaning in C. They must not be used for any +other purposes. Keywords are case sensitive. + + + Keyword | Description + ---------------+---------------------------- + $ auto $| storage-class specifier + $ break $| statement + $ case $| label + $ char $| type + $ const $| type qualifier + $ continue $| statement + $ default $| label + $ do $| statement + $ double $| type + $ else $| statement + $ enum $| type + $ extern $| storage-class specifier + $ float $| type + $ for $| statement + $ goto $| statement + $ if $| statement + $ inline $| function specifier + $ int $| type + $ long $| type + $ register $| storage-class specifier + $ restrict $| type qualifier + $ return $| statement + $ short $| type + $ signed $| type + $ sizeof $| operator + $ static $| storage-class specifier + $ struct $| specifier + $ switch $| statement + $ typedef $| declaration + $ union $| specifier + $ unsigned $| type + $ void $| type + $ volatile $| type qualifier + $ while $| statement + $ _Bool $| type + $ _Complex $| type + $ _Imaginary $| type + + + + +============================================================================== +I.3 Operators *crv-operators* + + +------------------------------------------------------------------------------ +I.3.1 Overview *crv-opOverview* + + + Operator | Usage | Description + --------------+-----------------+------------------------------------------- + | | + |crv-opArithmetic| +Arithmetic~ +$ +$[unary] |$+operand $| positive sign, same like$operand$ +$ -$[unary] |$-operand $| negation of$operand$ + | | +$ +$[binary] |$expr1 + expr2 $| addition +$ -$[binary] |$expr1 - expr2 $| substraction +$ / $ |$expr1 / expr2 $| division +$ * $ |$expr1 * expr2 $| multiplication +$ % $ |$expr1 % expr2 $| modulo +$ --$[postfix] |$operand-- $|$operand$before decrementing by 1 +$ --$[prefix] |$--operand $|$operand$after decrementing by 1 +$ ++$[postfix] |$operand++ $|$operand$before incrementing by 1 +$ ++$[prefix] |$++operand $|$operand$after incrementing by 1 + | | + |crv-opLogical| +Logical~ +$ && $ |$expr1 && expr2 $| logical AND +$ || $ |$expr1 || expr2 $| logical OR +$ ! $ |$!expr1 $| logical NOT + | | + |crv-opRelational| +Relational~ +$ ==$ |$expr1 == expr2 $| compare for equal +$ !=$ |$expr1 != expr2 $| compare for not equal +$ > $ |$expr1 > expr2 $| compare for "greater than" +$ < $ |$expr1 < expr2 $| compare for "less than" +$ >=$ |$expr1 >= expr2 $| compare for "greater than or equal" +$ <=$ |$expr1 <= expr2 $| compare for "less than or equal" + | | + |crv-opBitwise| +Bitwise~ +$ & $ |$expr1 & expr2 $| bitwise AND +$ | $ |$expr1 | expr2 $| bitwise OR +$ ^ $ |$expr1 ^ expr2 $| bitwise XOR +$ << $ |$expr1 << expr2 $| shift bits to left +$ >> $ |$expr1 >> expr2 $| shift bits to right +$ ~ $ |$~expr1 $| one's complement + | | + |crv-opAssigns| +Assignment~ +$ = $ |$expr1 = expr2 $| assignment +$ *= $ |$expr1 *= expr2 $|$expr1 = expr1 * expr2 $ +$ /= $ |$expr1 /= expr2 $|$expr1 = expr1 / expr2 $ +$ %= $ |$expr1 %= expr2 $|$expr1 = expr1 % expr2 $ +$ += $ |$expr1 += expr2 $|$expr1 = expr1 + expr2 $ +$ -= $ |$expr1 -= expr2 $|$expr1 = expr1 - expr2 $ +$ <<=$ |$expr1 <<= expr2$|$expr1 = expr1 << expr2 $ +$ >>=$ |$expr1 >>= expr2$|$expr1 = expr1 >> expr2 $ +$ &= $ |$expr1 &= expr2 $|$expr1 = expr1 & expr2 $ +$ ^= $ |$expr1 ^= expr2 $|$expr1 = expr1 ^ expr2 $ +$ |= $ |$expr1 |= expr2 $|$expr1 = expr1 | expr2 $ + | | + |crv-opOthers| +Others~ +$ sizeof $ |$sizeof a $| size of element$a$in bytes +$ & $ |$&expr1 $| address of$expr1$ +$ * $ |$*expr1 $| contents of$expr1$, $expr1$is a pointer +$ ?: $ |$a?expr1:expr2 $| conditional operator$a!=0:expr1 else expr2$ +$ , $ |$expr1,expr2 $| comma operator +$(type-name)$ |$(float)expr1 $| explicit type cast +$ . $ |$a.b $| struct/union selector,$a$is struct/union +$ -> $ |$a->b $| struct/union selector,$a$is pointer to + | | struct/union +$ [] $ |$a[0] $| array selector +$ () $ |$(a + b) * c $| group operators or + |$func() $| declare functions + | | + --------------+-----------------+------------------------------------------- + + +The sections below give further information on operators. + + +------------------------------------------------------------------------------ +I.3.2 Arithmetic *crv-opArithmetic* + +$+operand$ *crv-opPosSign* +---------- +positive sign + +Examples: > + a = +15; + a = +b; + func(3.12E+3); + + +$-operand$ *crv-opNegSign* +---------- +negative sign, negation + +Examples: > + a = -15; + a = -a; + + +$expr1 + expr2$ *crv-opAdd* +--------------- +This adds the two expressions. + +Examples: > + a = b + c; + a = b + 42; + a = func(b + c); + + +$expr1 - expr2$ *crv-opSub* +--------------- +Substract$expr2$from$expr1$. + +Examples: > + a = b - c; + a = b - 42; + a = func(b - c); + + +$expr1 / expr2$ *crv-opDivide* +--------------- +Divide$expr1$by$expr2$. +If$expr2$is 0, behavior is undefined. + +Examples: > + a = b / c; + a = b / 42; + a = func(c / 3); + + +$expr1 * expr2$ *crv-opMultiply* +--------------- +Multiply$expr1$by$expr2$. + +Examples: > + a = b * c; + a = b * 42; + a = func(c * 3); + + +$expr1 % expr2$ *crv-opModulo* +--------------- +Modulo operator. The result is the value of the remainder after +dividing$expr1$by$expr2$. +Both expressions must be integer types (char, short, int, long..., +signed or unsigned). +If$expr2$is 0, behavior is undefined. + +Examples: > + a = 0 % 3; // result = 0 + a = 1 % 3; // result = 1 + a = 2 % 3; // result = 2 + a = 3 % 3; // result = 0 + a = 4 % 3; // result = 1 + a = 5 % 3; // result = 2 + a = 6 % 3; // result = 0 + a = 7 % 3; // result = 1 + a = 7 % (-3); // result = 1 + a = (-7) % 3; // result = -1 + a = (-7) % (-3); // result = -1 + + a = b % c; + func(a % c); + + +$operand--$ *crv-opPostDec* +----------- +This is a postfix operation (unary operator after operand). +$operand$will be decremented by 1 AFTER the expression is +evaluated. +The value 1 of the appropriate type is subtracted. +So e.g. integer and float can be used as$operand$. + +Example: > + int nA; + float fA; + + nA = 3; + printf("%d", nA--); // output 3 + printf("%d", nA); // output 2 + + fA = 3.2f; + fA--; + printf("%f", fA); // output 2.2 + + +$--operand$ *crv-opPreDec* +----------- +This is a prefix operation (unary operator before operand). +$operand$will be decremented by 1 BEFORE the expression is +evaluated. +The value 1 of the appropriate type is subtracted. +So e.g. integer and float can be used as$operand$. + +Example: > + int nA; + float fA; + + nA = 3; + printf("%d", --nA); // output 2 + printf("%d", nA); // output 2 + + fA = 3.2f; + --fA; + printf("%f", fA); // output 2.2 + + +$operand++$ *crv-opPostInc* +----------- +This is a postfix operation (unary operator after operand). +$operand$will be incremented by 1 AFTER the expression is +evaluated. +The value 1 of the appropriate type is added. So e.g. +integer and float can be used as$operand$. + +Example: > + int nA; + float fA; + + nA = 3; + printf("%d", nA++); // output 3 + printf("%d", nA); // output 4 + + fA = 3.2f; + fA++; + printf("%f", fA); // output 4.2 + + +$++operand$ *crv-PreInc* +----------- +This is a prefix operation (unary operator before operand). +$operand$will be incremented by 1 BEFORE the expression is +evaluated. +The value 1 of the appropriate type is added. So e.g. +integer and float can be used as$operand$. + +Example: > + int nA; + float fA; + + nA = 3; + printf("%d", ++nA); // output 4 + printf("%d", nA); // output 4 + + fA = 3.2f; + ++fA; + printf("%f", fA); // output 4.2 + + + +------------------------------------------------------------------------------ +I.3.3 Logical *crv-opLogical* + +An expression is FALSE if its value is 0, else it is TRUE. + +ATTENTION: This means TRUE is defined as unequal to 0. So never assume any +value for TRUE, TRUE's value depends on implementation. + + +$expr1 && expr2$ *crv-opLogAnd* +---------------- +This is the logical AND. +The expression is TRUE if both$expr1$AND$expr2$are TRUE - else it is FALSE. +If$expr1$is equal 0,$expr2$is not evaluated. +The result has type$int$. + + $expr1$|$expr2$ || result + --------+--------++-------- + 0 | 0 || 0 + 0 | >=1 || 0 + >=1 | 0 || 0 + >=1 | >=1 || >=1 + + +$expr1 || expr2$ *crv-opLogOr* +---------------- +This is the logical OR. +The expression is TRUE if either$expr1$OR$expr2$is TRUE - else it is FALSE. +If$expr1$is unequal 0,$expr2$is not evaluated. +The result has type$int$. + + $expr1$|$expr2$ || result + --------+--------++-------- + 0 | 0 || 0 + 0 | >=1 || >=1 + >=1 | 0 || >=1 + >=1 | >=1 || >=1 + + +$!expr1$ *crv-opLogNot* +-------- +This is the logical NOT. +The expression is TRUE if$expr1$is FALSE. The expression is FALSE if$expr1$is +TRUE. +The result has type$int$. + + $expr1$|| result + ------++-------- + 0 || >=1 + >=1 || 0 + + + +------------------------------------------------------------------------------ +I.3.4 Relational *crv-opRelational* + +$expr1 == expr2$ *crv-opRelEqual* +---------------- +Equality operator. The result is 1 if operands are equal. The result is +0 if operands are unequal. +The result has type$int$. + +Example: > + int x, a, b; + + a = 1; + b = 2; + + if (a == 1) + { + printf("a is equal to 1"); + } + + x = a == b; + printf("%d", x); // output is 0, since a != b + + +$expr1 != expr2$ *crv-opRelUnequal* +---------------- +Unequality operator. The result is 1 if operands are unequal. The result is +0 if operands are equal. +The result has type$int$. + +Example: > + int x, a, b; + + a = 1; + b = 2; + + if (a != b) + { + printf("a is unequal to b"); + } + + x = a != b; + printf("%d", x); // output is 1, since a != b + + +$expr1 > expr2$ *crv-opRelGT* +--------------- +"greater than" operator. The result is 1 if value of$expr1$is greater than +value of $expr2$, else result is 0. +The result has type$int$. + +Example: > + int x, a, b; + + a = 5; + b = 2; + + if (a > b) + { + printf("a is greater than b"); + } + + x = a > b; + printf("%d", x); // output is 1, since a > b + + +$expr1 < expr2$ *crv-opRelLT* +--------------- +"less than" operator. The result is 1 if value of$expr1$is less than +value of$expr2$, else result is 0. +The result has type$int$. + +Example: > + int x, a, b; + + a = 1; + b = 2; + + if (a < b) + { + printf("a is less than b"); + } + + x = a < b; + printf("%d", x); // output is 1, since a < b + + +$expr1 >= expr2$ *crv-opRelGTE* +---------------- +"greater than or equal to" operator. The result is 1 if value of$expr1$is +greater than or equal to value of$expr2$, else result is 0. +The result has type$int$. + +Example: > + int x, a, b; + + a = 1; + b = 1; + + if (a >= b) + { + printf("a is greater than or equal to b"); + } + + a = 1; b = 2; + x = a >= b; + printf("%d", x); // output is 0, since a < b + + +$expr1 <= expr2$ *crv-opRelLTE* +---------------- +"less than or equal to" operator. The result is 1 if value of$expr1$is +less than or equal to value of$expr2$, else result is 0. +The result has type$int$. + +Example: > + int x, a, b; + + a = 1; + b = 2; + + if (a <= b) + { + printf("a is less than or equal to b"); + } + + x = a <= b; + printf("%d", x); // output is 1, since a <= b + + + +------------------------------------------------------------------------------ +I.3.5 Bitwise *crv-opBitwise* + +$expr1 & expr2$ *crv-opBitAnd* +--------------- +Bitwise AND operator. This operator does a bitwise AND on the values +of$expr1$and$expr2$. +The result is a value the same size as the expressions. + + $expr1$ | $expr2$ || result + n-th Bit | n-th Bit || n-th Bit + ----------+-----------++---------- + 0 | 0 || 0 + 0 | 1 || 0 + 1 | 0 || 0 + 1 | 1 || 1 + +Example: > + int a, b; + + b = 0x81; + a = b & 0xF0; + // value of a is: 0x80 + + +$expr1 | expr2$ *crv-opBitOr* +--------------- +Bitwise OR operator. This operator does a bitwise OR on the values +of$expr1$and$expr2$. +The result is a value the same size as the expressions. + + $expr1$ | $expr2$ || result + n-th Bit | n-th Bit || n-th Bit + ----------+-----------++---------- + 0 | 0 || 0 + 0 | 1 || 1 + 1 | 0 || 1 + 1 | 1 || 1 + +Example: > + int a, b; + + b = 0x81; + a = b | 0xF0; + // value of a is: 0xF1 + + +$expr1 ^ expr2$ *crv-opBitXor* +--------------- +Bitwise XOR operator. This operator does a bitwise XOR on the values +of$expr1$and$expr2$. +The result is a value the same size as the expressions. + + $expr1$ | $expr2$ || result + n-th Bit | n-th Bit || n-th Bit + ----------+-----------++---------- + 0 | 0 || 0 + 0 | 1 || 1 + 1 | 0 || 1 + 1 | 1 || 0 + +Example: > + int a, b; + + b = 0x81; + a = b ^ 0xF0; + // value of a is: 0x71 + + +$expr1 << expr2$ *crv-opBitLeftShift* +---------------- +Bitwise left-shift operator. The result is$expr1$left-shifted$expr2$bit +positions, vacated bits are filled with 0. + +IF$expr1$is an unsigned type the value of the result is: + $expr1$* 2^($expr2$) modulo (1 + maximum value representable in resulting + type) +ELSE + IF$expr1$is a signed type and has a nonnegative value and + $expr1$* 2^($expr2$) is representable in the result type then the + result is: + $expr1$* 2^($expr2$) + ELSE + behavior is undefined + +Both expressions must be integer types (char, short, int, long..., +signed or unsigned). +The result has the type of$expr1$. +If the value of$expr2$is negative or is greater than or equal to the +width of$expr1$, the behavior is implementation specific. + +Example: > + int a, b, c; + + a = 3; + b = 2; + c = a << b; + // value of c is 12 + + +$expr1 >> expr2$ *crv-opBitRightShift* +---------------- +Bitwise right-shift operator. The result is$expr1$right-shifted$expr2$ +bit positions. + +If$expr1$has an unsigned type or if$expr1$has a signed type and a nonnegative +value, the result is: + $expr1$/ 2^($expr2$) + +If$expr1$has a signed type and a negative value, the result is implementation +specific. Many compilers set vacated bits to 1. + +Example: > + int a, b, c; + + a = 17; + b = 2; + c = a >> b; + // value of c is 4 + + +$~expr1$ *crv-opBitCompl* +-------- +Bitwise one's complement. A bit in the result is set if the corresponding bit +in$expr1$is not set. A bit in the result is cleared if the corresponding bit +in$expr1$is set. + +The expression must has an integer type (char, short, int, long..., +signed or unsigned). The result has the type of$expr1$. + +Example: > + int a, b; + + a = 0xF0; + b = ~a; + // value of b is 0x0F + + + +------------------------------------------------------------------------------ +I.3.6 Assignments *crv-opAssigns* + + +$expr1 = expr2$ *crv-opAsAssign* +--------------- +The value of$expr2$is assigned to$expr1$. + +Example: > + int a, b; + + a = 2; + b = 3; + b = a * b; + + +$expr1 *= expr2$ *crv-opAsMul* +---------------- +Assign$expr1$the value of$expr1$multiplied by$expr2$. + +Same as: $expr1 = expr1 * expr2$ + +see |crv-opMultiply| + +Example: > + int a, b; + + a = 2; + b = 3; + a *= b; + // a has value 6 + + +$expr1 /= expr2$ *crv-opAsDiv* +---------------- +Assign$expr1$the value of$expr1$divided by$expr2$. + +Same as: $expr1 = expr1 / expr2$ + +see |crv-opDivide| + +Example: > + int a, b; + + a = 6; + b = 3; + a /= b; + // a has value 2 + + +$expr1 %= expr2$ *crv-opAsModulo* +---------------- +Assign$expr1$the remainder after dividing$expr1$by$expr2$. + +Same as: $expr1 = expr1 % expr2$ + +see |crv-opModulo| + +Example: > + int a, b; + + a = 6; + b = 3; + a %= b; + // a has value 0 + + +$expr1 += expr2$ *crv-opAsAdd* +---------------- +Assign$expr1$the value of the sum of$expr1$and$expr2$. + +Same as: $expr1 = expr1 + expr2$ + +see |crv-opAdd| + +Example: > + int a, b; + + a = 6; + b = 3; + a += b; + // a has value 9 + + + +$expr1 -= expr2$ *crv-opAsSub* +---------------- +Assign$expr1$the value of$expr2$substracted by$expr1$. + +Same as: $expr1 = expr1 - expr2$ + +see |crv-opSub| + +Example: > + int a, b; + + a = 6; + b = 4; + a -= b; + // a has value 2 + + +$expr1 <<= expr2$ *crv-opAsLeftShift* +----------------- +Assign$expr1$the value of$expr1$left-shifted by$expr2$bit positions. + +Same as: $expr1 = expr1 << expr2$ + +see |crv-opBitLeftShift| + +Example: > + int a, b; + + a = 6; + b = 2; + a <<= b; + // a has value 24 + + +$expr1 >>= expr2$ *op-opAsRightShift* +----------------- +Assign$expr1$the value of$expr1$right-shifted by$expr2$bit positions. + +Same as: $expr1 = expr1 >> expr2$ + +see |crv-opBitRightShift| + +Example: > + int a, b; + + a = 6; + b = 1; + a >>= b; + // a has value 3 + + +$expr1 &= expr2$ *opAsBitAnd* +---------------- +Assign$expr1$the value of the bitwise AND of$expr1$and$expr2$. + +Same as: $expr1 = expr1 & expr2$ + +see |crv-opBitAnd| + +Example: > + int a, b; + + a = 0x81; + b = 0x0F; + a &= b; + // a has value 0x01 + + +$expr1 ^= expr2$ *opAsBitXor* +---------------- +Assign$expr1$the value of the bitwise XOR of$expr1$and$expr2$. + +Same as: $expr1 = expr1 ^ expr2$ + +see |crv-opBitXor| + +Example: > + int a, b; + + a = 0x81; + b = 0x0F; + a &= b; + // a has value 0x01 + + +$expr1 |= expr2$ *opAsBitOr* +---------------- +Assign$expr1$the value of the bitwise OR of$expr1$and$expr2$. + +Same as: $expr1 = expr1 | expr2$ + +see |crv-opBitOr| + +Example: > + int a, b; + + a = 0x81; + b = 0x0F; + a |= b; + // a has value 0x8F + + + +------------------------------------------------------------------------------ +I.3.7 Others *crv-opOthers* + +I.3.7.1 Size of *crv-opSizeOf* +---------------- +Operator: $sizeof$ *crv-sizeof* +Declaration: + $size_t sizeof expression$ + or + $size_t sizeof (type-name)$ + +The$sizeof$operator yields the size of its operand (number of bytes). +The operand is either an expression or a name of a type. The name of type +must be in parenthesis. +The result has type$size_t$which is an unsigned integer type (unsigned int, +unsigned long,.... implementation specific). + +The result for$char$,$unsigned char$,$signed char$or a typedef of them is 1. +For arrays the result is the total number of bytes used by the object. +For structures or unions the result is the total number of bytes in the +object including pad-bytes added by the compiler for alignment. + +Examples: > + char a[7]; + printf("%d", sizeof a ); // prints 7 + printf("%d", sizeof a[0] ); // prints 1 + + printf("%d", sizeof(float) ); // prints 4 + + -------- + + struct Test { + char ch; + float f; + } tst; + + printf("%d", sizeof(tst) ); // print 8 (impl. specific) + printf("%d", sizeof(struct Test) ); // print 8 (impl. specific) + + + +I.3.7.2 Address of *crv-opAddress* +------------------- +Syntax: $&operand$ + +The$&$operator returns the address of its operand. If the operand has type +"type" the result has type "pointer to type". + +Operand can be: + - a data type that is not register nor bit-fields + - function designator + - the result of$[]$operator + - the result of$*$operator + + +Example: > + int a, *ptr; + + a = 3; + ptr = &a; // assign address of a to prt + + printf("a: value = %d, address = %p", a, ptr); + + +I.3.7.3 Contents of *crv-opContents* +-------------------- +Syntax: $*operand$ + +The$*$operator refers to the value of the object a pointer points to. +The operand must be a pointer type. +If the operand has type "pointer to type" the result has type "type". + +Example: > + int a, b, *ptr; + + ptr = &a; // assign address of a to prt + *ptr = 5 // set value of object ptr points to to 5 (object is a) + b = *ptr; // assign value of object pointer ptr points to to b + + +I.3.7.4 Conditional *crv-opConditional* +-------------------- +Syntax: $expr1 ? expr2 : expr3$ + +At first$expr1$is evaluated. If$expr1$is unequal 0,$expr2$is evaluated. +If$expr1$is equal 0,$expr3$is evaluated. + +The result of the conditional operator is either the value of$expr2$or$expr3$, +whichever is evaluated. The type of the result is: + - If$expr2$and$expr3$have the same type, the result has that type. + - If$expr2$and$expr3$have different types, the result has the type + that would be determined by the usual arithmetic conversions, were they + applied to$expr2$and$expr3$. + +Example: > + int a, b, max; + + a = 2; + b = 5; + + max = a > b ? a : b; // get maximum of a and b + + a == 2 ? FuncA() : FuncB(); // call FuncA() if a == 2, else call FuncB() + + +I.3.7.5 Series *crv-opSeries* +--------------- +Syntax: $expr1, expr2$ + +The comma operator$,$ allows to put two separate expressions where one is +required. +At first$expr1$is evaluated. Then$expr2$is evaluated. The result of the +comma operator has the value and type of$expr2$. + +It is allowed to nest expressions. + +Example: > + int i, j, k; + + for (i=0, j=15, k=2; i < 5; i++, j--) + { + .... + } + + func(3, (i=3, i+6), k); // second parameter has value 9 and type int + + + +I.3.7.6 Type Cast *crv-opTypeCast* +------------------ +Syntax: $(type-name)expr1$ + +The type cast operator converts the value of$expr1$to$type-name$. + +Examples: > + int a, b; + float f; + + a = 5; + b = 10; + + f = a / b; + // f has value 0, integer division + + f = (float)a / (float)b; + // f has value 0.5 + + +I.3.7.7 Struct/Union Selectors *crv-opStructUnionSel* +------------------------------- +- Struct/Union: $expr1.identifier$ +The$.$operator selects a member of a structure or union. +$expr1$has the type of a structure or union. + + +- Pointer to Struct/Union: $expr1->identifier$ +The$->$operator selects a member of a structure or union. +$expr1$has the type of "pointer to structure" or +"pointer to union". + +Examples: > + struct Example { + int element1; + float element2; + } expl; + + struct Example *ptr; + + ptr = &expl; + + expl.element1 = 2; + ptr->element2 = 42.0f; + + +I.3.7.8 Array Selector *crv-opArraySel* +----------------------- +Syntax: $expr1[expr2]...[exprN]$ + +Selects an element of an array. First element has index 0. + +Examples: > + int a[3] = {1,2,3}; + int b[2][3] = { {1,2,3}, {4,5,6}}; + + printf("%d\n", b[1][0]); // output 4 + + a[2] = 0; // array a contains {1,2,0} + + +I.3.7.9 Parentheses *crv-opParenth* +-------------------- +Operator:$()$ + +The parentheses-operator is used for: + +- group expressions + $a = (b + 2) * c$ + +- declare functions + $a = func(b, c + 1)$ + +- explicit type-cast (see |crv-opTypeCast|) + +- statements like + $if (...)$ + $for (...)$ + $while(...)$ + .... + + +------------------------------------------------------------------------------ +I.3.8 Precedence *crv-opPrecedence* + +The precedence defines which operator is done before other ones +(e.g.$a + b * c$: at first the multiplication is done then the addition). +The following table shows the order of precedence, operators at the top have +highest precedence. + + + Operator | Associativity + ---------------------------------------+---------------- +$ () [] -> . $| left to right +$ ! ~ ++ -- + - (type-name) * & sizeof $| right to left (unary operators) +$ * / % $| left to right +$ + - $| left to right +$ << >> $| left to right +$ < <= > >= $| left to right +$ == != $| left to right +$ & $| left to right +$ ^ $| left to right +$ | $| left to right +$ && $| left to right +$ || $| left to right +$ ?: $| right to left +$ = += -= /= *= %= >>= <<= &= |= ^= $| right to left +$ , $| left to right + + +If operators have the same order of precedence, the associativity defines +the order in which operators are done: +E.g. + $ a - b - c$ +is done as + $(a - b) - c$ +(from left to right) + + +NOTE: Precedence and associativity define which operator is done before +other ones. But the order of evaluation of subexpressions is unspecified, +except from function-call$()$,$&&$,$||$,$?:$and$,$. The order in which side +effects take place is unspecified too. + + Example: + $a = b + c * d;$ + + Because of the precedence a compiler has to calculate$c*d$and has + to add$b$and has to assign the result of that whole expression to$a$. + This is defined in the C standard. But a compiler is free to take e.g. + $b$and save it, then take$c$and then$d$and do$c*d$, add the saved value + of$b$and assign result to$a$. Or do any other order of evaluating the + subexpressions. + There are just a few operators that force compilers to a specified + sequence of evaluating subexpressions (see paragraph above). + + But of course the order of evaluating subexpressions can be relevant: + Example: > + int a = 4; + int b; + + b = ((a=2) * (a*=3)); // b either 12 or 24? + // a either 2 or 6? compiler specific +< + If the compiler takes first the expression$(a=2)$and then$(a*=3)$the + result will be 12. But if the compiler takes first$(a*=3)$and then + $(a=2)$the result will be 24. + + NOTE: Never ever write code that depends on the order of evaluating + expressions. + + + + +============================================================================== +I.4 Punctuators *crv-punctuators* + +Punctuators are special characters, they are not operands or identifiers. +They have their own semantic and syntactic. + + Punctuator | Example | Description + ------------+------------------------+--------------------------------------- +$ < > $| <stdio.h> | header name +$ [ ] $| n = a[3]; | array delimiter +$ ( ) $| func(a, b); | function parameter list or + | | expression grouping +$ { } $| char ch[2]={'a', 'b'}; | function body, initializer list, + | | compound statement +$ * $| int *ptr; | pointer declaration +$ # $| #include | preprocessor directive +$ , $| char ch[2]={'a', 'b'}; | argument list separator +$ : $| label: | label +$ ; $| a = b + c; | end of statement +$ ... $| func(int a, ...) | variable length of argument list +$ = $| int n = 2; | declaration initializer +$ ' ' $| char ch = 'a'; | character constant +$ " " $| char ch[] = "abc"; | string constant or header file name + + + + +============================================================================== +I.5 Datatypes *crv-datatypes* + + +------------------------------------------------------------------------------ +I.5.1 Overview *crv-dtOverview* + +I.5.1.1 Type Specifiers *crv-dtTypeSpecifiers* +------------------------ +To specify a datatype in standard C the following type-specifiers are +allowed: + + $void $ + $char $ *crv-char* + $short $ *crv-short* + $int $ *crv-int* + $long $ *crv-long* + $float $ *crv-float* + $double $ *crv-double* + $signed $ *crv-signed* + $unsigned $ *crv-unsigned* + $_Bool $ *crv-_Bool* + $_Complex $ *crv-_Complex* + $_Imaginary$ *crv-_Imaginary* + $struct $ + $union $ + $enum $ + $typedef-name$ + + +Type specifiers can be combined, the whole set of possible type specifiers is +viewed in the table below. Specifiers given in the same row have the same +meaning. + + + Type Specifier | Description + =========================+================================================== +$void $| empty or NULL value + -------------------------+-------------------------------------------------- +$char $| store member of basic character set +$signed char $| + -------------------------+-------------------------------------------------- +$unsigned char $| same as char, but unsigned values only + -------------------------+-------------------------------------------------- +$short $| defines a short signed integer +$short int $| +$signed short $| +$signed short int $| + -------------------------+-------------------------------------------------- +$unsigned short $| same as short, but unsigned values only +$unsigned short int $| + -------------------------+-------------------------------------------------- +$int $| defines a signed integer +$signed $| +$signed int $| + -------------------------+-------------------------------------------------- +$unsigned $| same as int, but unsigned values only +$unsigned int $| + -------------------------+-------------------------------------------------- +$long $| defines a long signed integer +$long int $| +$signed long $| +$signed long int $| + -------------------------+-------------------------------------------------- +$unsigned long $| same as long, but unsigned values only +$unsigned long int $| + -------------------------+-------------------------------------------------- +$long long $| defines a long long signed integer +$long long int $| +$signed long long $| +$signed long long int $| + -------------------------+-------------------------------------------------- +$unsigned long long $| same as long long, but unsigned values only +$unsigned long long int $| + -------------------------+-------------------------------------------------- +$float $| defines a floating-point number + -------------------------+-------------------------------------------------- +$double $| defines a more accurate floating-point number + | than float + -------------------------+-------------------------------------------------- +$long double $| defines a more accurate floating-point number + | than double + -------------------------+-------------------------------------------------- +$_Bool $| defines a Bool-integer (0 or 1 only) + -------------------------+-------------------------------------------------- +$float _Complex $| defines a complex number with floating + -------------------------+-------------------------------------------------- +$double _Complex $| defines a complex number more accurate + | than the float type + -------------------------+-------------------------------------------------- +$long double _Complex $| defines a complex number more accurate than + | the double type + -------------------------+-------------------------------------------------- +$float _Imaginary $| defines an imaginary number with floating + -------------------------+-------------------------------------------------- +$double _Imaginary $| defines an imaginary number more accurate + | than the float type + -------------------------+-------------------------------------------------- +$long double _Imaginary $| defines an imaginary number more accurate than + | the double type + -------------------------+-------------------------------------------------- +$struct $| defines a set of elements that have possibly + | different datatypes (unlike an array) + -------------------------+-------------------------------------------------- +$union $| defines a set of elements that have possibly + | different datatypes and use the same overlapping + | memory (total size is size of biggest element) + -------------------------+-------------------------------------------------- +$enum $| defines a set of named integer constant values + -------------------------+-------------------------------------------------- +$typedef-name $| a new named type defined with the$typedef$ + | keyword, the new type is a synonym for one of the + | types listed above + =========================+================================================== + + + +I.5.1.2 Type Grouping *crv-dtTypeGrouping* +---------------------- + +The types can be grouped in this way: + + + TYPE + | + -------------------+-----------+------------- + | | | + | | | + ------- SCALAR ----- AGGREGATE $void$ + | | | + | | +------------- + | | | | + - ARITHMETIC --- $pointers$ ARRAY STRUCTURE + | | | | + | | | | +INTEGER - FLOATING -+----------- $array$ -$struct$- + | | | | | | + | | | | | | + | REAL COMPLEX IMAGINARY $union bit-field$ + | | | | + | | | $_Imaginary$(1) + | | | | + | | | +-------+--------- + | | | | | | + | | | $float double long double$ + | | | + | | | + | | $_Complex$(1) + | | | + | | +-------+--------- + | | | | | + | | $float double long double$ + | | + | | + | +-------+--------- + | | | | + | $float double long double$ + | + | + +-----------------+---------------+--------- + | | | | +$char short enum _Bool$ +$signed/unsigned int $ +$ long $ +$ long long $ +$ signed/unsigned $ + + + (1): implementation of these datatypes is not required + + +The basic types are type char, signed/unsigned integer types and floating +types. + + + + +------------------------------------------------------------------------------ +I.5.2 Sizes and Ranges *crv-dtSizeRange* + + +The C standard defines the basic types as having a "at least" size. + + Type | Size/Range + ============+=================================================== +$char $| large enough to store any member of the basic + | character set + ------------+--------------------------------------------------- +$short $| same as int or smaller range + ------------+--------------------------------------------------- +$int $| has the natural size suggested by the architecture + | of the execution environment + ------------+--------------------------------------------------- +$long $| same as int or greater range + ------------+--------------------------------------------------- +$long long $| same as long or greater range + ------------+--------------------------------------------------- +$float $| IEEE-754 floating-point standard, single format + ------------+-------------------------------------------------- +$double $| IEEE-754 floating-point standard, double format + ------------+--------------------------------------------------- +$long double$| shall have more precision than double and at + | least the range of double + ------------+--------------------------------------------------- +$_Bool $| large enough to store values 0 and 1 + ============+=================================================== + + + +Common - but not guaranteed - values are: + + + Type | Size/Range + | 16-bit Architecture 32-bit Architecture + ============+================================================================ +$char $| 8 bit + | 0...255 + | -128...127 + ------------+---------------------------------------------------------------- +$short $| 16 bit + | 0...65535 + | -32768...32767 + ------------+---------------------------------------------------------------- +$int $| 16 bit | 32 bit + | 0...65535 | 0...4,294,967,295 + | -32768...32767 | -2,147,483,648...2,147,483,647 + ------------+---------------------------------------------------------------- +$long $| 32 bit + | 0...4,294,967,295 + | -2,147,483,648...2,147,483,647 + ------------+---------------------------------------------------------------- +$long long $| 64 bit + | 0...18,446,744,073,709,551,615 + | -9,223,372,036,854,775,808...9,223,372,036,854,775,807 + ------------+---------------------------------------------------------------- +$float $| 32 bit + | magnitudes: 1.175494351e-38...3.402823466e+38 + | significant digits: >= 6 + | given x, next is: x * (1 + 1.192092896e-7) + ------------+---------------------------------------------------------------- +$double $| 64 bits + | magnitudes: 2.2250738585072014e-308...1.7976931348623158e+308 + | significant digits: >= 15 + | given x, next is: x * (1 + 2.2204460492503131e-16) + ------------+---------------------------------------------------------------- +$long double$| 96 bits, 80 bits used + | magnitudes: 3.36210314311209351e-4932 1.18973149535723177e+4932 + | significant digits: >= 18 + | given x, next is: x * (1 + 1.08420217248550443e-19) + ------------+---------------------------------------------------------------- +$_Bool $| 16 bit | 32 bit + | 0, 1 | 0, 1 + ============+================================================================ + + + + +------------------------------------------------------------------------------ +I.5.2 Formats *crv-dtFormats* + +I.5.2.1 Integer *crv-dtFormatsInt* +---------------- + +Integer values are represented as binary numbers (base 2). + +The range of unsinged integer types is 0...2^(N-1), whereas N is the size +of the integer type (8, 16, 32, 64 bit...). + +Value = bitN*2^(N-1) + ... + bit3*2^3 + bit2*2^2 + bit1*2^1 + bit0*2^0 + +N is the most significant bit, 0 the least significant. + +For signed integer values one bit is used as sign, commonly the most +significant bit. +If sign bit is 0, the representation is the same as for unsigned integer. +If sign bit is 1, a negative value is represented. There are three +possibilities to represent a negative value: + + - Sign-Magnitude *crv-signMagnitude* + -------------- + Sign bit 0: the rest is a positive number + Sign bit 1: the rest is a negative number + E.g.: + 0000 1001 = +9 + 1000 1001 = -9 + + Attributs: + +0 and -0 exists + Range: -2^(N-1) - 1 ... 2^(N-1) - 1 (e.g. 8bit: -127 ... +127) + adding, subtracting, dividing, multiplying needs extra logic + conversion from positive to negative values and vice versa is simple + + - One's Complement *crv-onesComplement* + ---------------- + The negative value is obtained by inverting all bits of the corresponding + positive value. + The most significant bit is the sign bit. Positive values have sign bit 0, + negative values have sign bit 1. + + Attributs: + +0 and -0 exists + Range: -2^(N-1) - 1 ... 2^(N-1) - 1 (e.g. 8bit: -127 ... +127) + conversion from positive to negative values and vice versa is simple + adding can be done directly, subtracting can be converted to adding + multiplication needs extra logic for sign + + - Two's Complement *crv-twosComplement* + ---------------- + The negative value is obtained by inverting all bits of the corresponding + positive value and adding 1. + The most significant bit is the sign bit. Positive values have sign bit 0, + negative values have sign bit 1. + + Attributs: + only one 0 exists + Range: -2^(N-1) ... 2^(N-1) - 1, asymetric (e.g. 8bit: -128 ... +127) + adding and multiplying is straight forward + sign extension when promoting is simple (repeat sign bit on the left) + +Which method is used to represent negative values is implementation specific, +commonly the two's complement is used. + + +Beneath decimal numbers (base 10), octal (base 8) and hexadecimal (base 16) +numbers can be used in standard C. + +Octal numbers start with a 0 (zero), hexadecimal start with a 0x (zero x). +Opposed to decimal numbers, conversions from and to binary is easier with +octal and hexadecimal numbers. +Octal groups 3 bits, one digit has range 0...7. +Hexadecimal groups 4 bits, one digit has range 0...9, A...F. + +Examples: + Bit + 15 14 13 12 11 10 9 8 | 7 6 5 4 3 2 1 0 + -------------------------------------------------- + 1 1 1 0 1 0 0 1 0 1 0 1 1 0 0 1 + | | | | | +octal: 1 | 6 | 4 | 5 | 3 | 1 = 0164531 + + + Bit + 15 14 13 12 11 10 9 8 | 7 6 5 4 3 2 1 0 + -------------------------------------------------- + 1 1 1 0 1 0 0 1 0 1 0 1 1 0 0 1 + | | | +hex: E | 9 | 5 | 9 = 0xE959 + + + + +I.5.2.2 Floating-Point *crv-dtFormatsFloat* +----------------------- + +I.5.2.2.1 Basics *crv-dtFormatsFPBasics* +----------------- +In standard C floating values are represented as described in the floating- +point standard IEC 60559 (previously IEEE-754). +NOTE: The standard does not define bit-positions! + +Generally a floating pointer number consists of four parts: + - sign + - mantissa + - radix + - exponent + + ---------------------------------------------- ~ + | value = sign * mantissa * radix^(exponent) |~ + ---------------------------------------------- ~ + +The sign is +1 or -1. The mantissa holds the significant digits of a +floating-point number and is always positive. +The exponent indicates the positive or negative power of the radix. To +be able to get positive and negative exponents a bias is added to the +actual exponent. + +A number can be expressed in many different ways, e.g.: + 3.0: 3.0 * 10^0 + 0.03 * 10^2 + 300 * 10^(-2) + ..... + +To maximize the quantity of representable numbers, floating-point numbers +are typically stored in a normalized form. +A normalized floating-point number has a mantissa that's leftmost digit +is non-zero. To normalize the mantissa is shifted left until the leftmost +digit is non-zero, the exponent is reduced by the number of shifts. +The normalized form of the number 3.0 would be: + 3.0 * 10^0 +A mantissa of a floating-point number fulfils the following equation: + + 1/radix <= mantissa < 1~ + +If this equation is not fulfilled, the floating-point number is called +denormalized. + +For bias 2 an optimization is available and exploited: for normalized +floating-point numbers the leftmost bit of the mantissa is always 1. +This bit don't need to be stored explicitly. We can assume it to be 1 so that +we get an extra bit to increase resolution (e.g. for float we have a 23 bit +mantissa, but a 24 bit resolution). + + +Special Values: *crv-dtFormatsFPValues* +--------------- +There are some special values explained below. + + Zero: *crv-dtFormatsFPZero* + ----- + All exponent and mantissa bits are set to 0. The sign bit can be set or + cleared, so that +0 and -0 is possible. Both are treated as 0.0. + + Note: There is no way to represent the value 0.0 in the format described + above. Because of normalization the leading digit must be unequal 0. + + Infinity: *crv-dtFormatsFPInfinity* + --------- + Infinity is signaled by all bits of exponent set and all bits of mantissa + cleared. The sign bit denotes +infinity and -infinity. + Infinity allows to handle overflows. + + NaN (Not a Number): *crv-dtFormatsFPNaN* + ------------------- + NaN is used to signal that the value is not a real number. NaN is denoted + by all exponent bits set and the mantissa != 0. + There are two types of NaN: Signalling NaN and Quiet NaN + Both indicates that something went wrong. + + Signalling NaN: + The most significant mantissa bit cleared denotes a signalling NaN. + A signalling NaN denotes an invalid operation (e.g. division by zero). + + Quiet NaN: + The most significant mantissa bit set denotes a quiet NaN. + A quiet NaN is set, if the result of an operation is not mathematically + defined. + + Denormalized: *crv-dtFormatsFPSDenorm* + ------------- + If the exponent is 0 and the mantissa is unequal 0, then the value is a + denormalized number. A denormalized number has no assumed 1 in the + mantissa. + + + +Special Operations: *crv-dtFormatsFPOp* +------------------- + + Operation | Result + -------------------------+------------ + n / +-infinity | 0 + +-nonzero / 0 | +-infinity + +-infinity * +-infinity | +-infinity + infinity + infinity | infinity + infinity - infinity | NaN + +-infinity / +-infinity | NaN + +-infinity * 0 | NaN + +-0 / +-0 | NaN + + + +I.5.2.2.2 Types *crv-dtFormatsFPTypes* +---------------- +Below commonly used floating-point formats are described. The bit positions +are not defined in standards, neither in standard C nor in IEEE-754. + +The radix is 2, so that the formula to get the value of a floating-point +number is: + + ------------------------------------------ ~ + | value = sign * mantissa * 2^(exponent) |~ + ------------------------------------------ ~ + +Float: *crv-dtFormatsFPFloat* +------ + Radix: 2 + Sign: 1 bit, = 0 positive, = 1 negative + Exponent: 8 bit, bias 127 + Mantissa: 23 bit, 24 bit resolution + Total Size: 32 bit + Range: 1.175494351e-38...3.402823466e+38 + Precision: >= 6 (number of digital digits of precision) + (see also |crv-dtSizeRange|) + + Bit: 31 30 23 22 0 + s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm + + s: signe + e: exponent + m: mantissa + + Examples: + s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm + 0.75 = 0 01111110 10000000000000000000000 + |___________ + | + e = 126 - 127 = -1 | + m = 1 (assume MSB 1) + 1/(2^1) + = 1.5 + value = 1.5 * 2^(-1) = 0.75 + + s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm + 12.75 = 0 10000010 10011000000000000000000 + | ||____________________________ + | |____________________ | + |___________ | | + | | | + e = 130 - 127 = 3 | | | + m = 1 (assume MSB 1) + 1/(2^1) + 1/(2^4) + 1/(2^5) + = 1.59375 + value = 1.59375 * 2^3 = 12.75 + + denormalized: + s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm + 1.46936...e-39 = 0 0000000 01000000000000000000000 + |________ + | + e = 0 - 127 = -127 | + m = 0 (no assumed MSB 1) + 1/(2^2) + = 0.25 + value = 0.25 * 2^(-127) = 1.4693679385278594e-39 + +Double: *crv-dtFormatsFPDouble* +------- + Radix: 2 + Sign: 1 bit, = 0 positive, = 1 negative + Exponent: 11 bit, bias 1023 + Mantissa: 52 bit, 53 bit resolution + Total Size: 64 bit + Range: 2.2250738585072014e-308...1.7976931348623158e+308 + Precision: >= 15 (number of digital digits of precision) + (see also |crv-dtSizeRange|) + + Bit: 63 62 52 51 0 + s eeeeeeeeeee mmmmmmmm...mmmmmmmmmmmm + + s: signe + e: exponent + m: mantissa + + +Long Double: *crv-dtFormatsFPLDouble* +------------ + Radix: 2 + Sign: 1 bit, = 0 positive, = 1 negative + Exponent: 15 bit, bias 16383 + Mantissa: 64 bit, 64 bit resolution(!), no assumed 1 in MSB + Total Size: 92 bit, 80 bit used + Range: 3.36210314311209351e-4932...1.18973149535723177e+4932 + Precision: >= 18 (number of digital digits of precision) + (see also |crv-dtSizeRange|) + + Bit: 79 78 64 63 0 + s eeeeeeeeeeeeeee mmmmmmmm...mmmmmmmmmmmm + + s: signe + e: exponent + m: mantissa + + +------------------------------------------------------------------------------ +I.5.3 void Type *crv-dtVoid* + *crv-void* +The$void$type specifies an empty or NULL type. This is used to: + - signify that a function does not return a value + - specify a function prototype with no arguments + - indicate a generic pointer + A generic pointer can point to any object type. No type cast is + necessary. + +Examples: + - function with no return value > + void Func(int n) + { + ... + } +< + - function with no arguments > + int Func (void) + { + ... + } +< + - generic pointer > + int i; + long l; + void *ptr; + + ptr = &i; + ptr = &l; +< + + + +------------------------------------------------------------------------------ +I.5.4 Arrays *crv-dtArrays* + +Syntax: +$storage-class-specifier type-specifier declarator[constant-expression$or$*];$ + +$storage-class-specifier$,$constant-expression$and$*$are optional + +Arrays are used to group data types of the same type. An array can be of any +data type, except$void$. + +When addressing an index within this array, indexing starts at 0 and ends +at array-size(in elements) - 1. + +An array has only one dimension. To get a multidemsional array an array of +array(s) can be declared. +The elements of arrays are stored in increasing addresses so that the +rightmost subscript varies most rapidly. +Example: $int n[2][3];$ + the elements are stored in this sequence: + n[0][0], n[0][1], n[0][2], n[1][0], n[1][1], n[1][2] + + It can be initialized with: + $int n[2][3] = { {0, 1, 2}, {3, 4, 5} };$ + + +Complete Array Type Declaration *crv-dtCompleteArrayDecl* +------------------------------- + +A complete array type declaration is a declaration of an array with known +size. The number of elements an array stores is specified at declaration. + +E.g.: $int array[2];$ + +The number of elements must be a constant value of >= 1 or a$*$. + +If a$*$is specified then the array type is a variable-length array type of +unspecified size, which can be used only in declarations with function +prototype scope. + + +Incomplete Array Type Declaration *drv-dtIncompleteArrayDecl* +--------------------------------- + +It is possible to declare an array of unknown size by omitting the size- +information at declaration. This sort of array declaration is called +incomplete array declaration. The size of an incomplete array declaration must +be specified elsewhere, so that the array type itself is complete. + +Incomplete array type declaration is useful for: + - When initializing at declaration. E.g.: > + char name1[] = "bert"; // end of string (0x00) is added automatically + char name2[] = {'b', 'e', 'r', 't', '\0'}; +< + The size of both arrays is 5 bytes. The initialization does complete the + array type. + + - To reference to an external defined array with known size: > + extern array[]; + + int main(void) + { + array[0] = 42; + .... + } +< + To work with this array, its size must be known of course. + + - For function parameter incomplete array type declaration can be used in the + function's declaration. E.g. > + void func(int array[]) + { + array[0] = 2; + } +< + A pointer must be passed to this function! + + +Initialization of Arrays *drv-dtArrayInit* +------------------------ + +Arrays can be initialized at definition time. It is allowed to initialized +less or all elements of a array. If less are initialized the remaining +elements are set to 0 automatically. + + Initialize all elements of the array, e.g.: + $int a[2] = {1, 2};$ + + Initialize the first elements, the rest is set to 0: + $int a[5] = {1, 2, 3};$ + Not allowed is to initialize more elements as the array can store: + $int a[5] = {1, 2, 3, 4, 5, 6}; // ERROR at compilation time$ + + Initialize multidimensional arrays: + $int b[2][3] = { {0, 1, 2}, {3, 4, 5} };$ + + Initialize incomplete arrays: + $char name1[] = "bert"; // end-of-string (0x00) is added$ + $char name2[] = {'b', 'e', 'r', 't', '\0'};$ + + Attention when assigning strings to arrays: + The end-of-string (0x00) is added only if the string fits into array: + $char ch[3] = "abc" // no end-of-string (0x00) is added here!$ + $char ch[4] = "abc" // end-of-string is added$ + $char ch[] = "abc" // end-of-string is added, array gets dimension of 4$ + + + +------------------------------------------------------------------------------ +I.5.5 Structures *crv-dtStructurs* + *crv-struct* +Syntax: + $struct$structur-name${$ + $variables,...$ + $}$structur-variable,...$;$ + + +Structures are used to group heterogenous data. The elements (members) of a +structure can be of different data types (opposed to arrays). All data types +are allowed, except$void$type. +The member names must be unique within a structure, but the same names can be +used in nested structures. +A structure cannot contain instances of themselves, but can have pointers +to instances of themselves as members. + +The members are stored sequentially in increasing addresses. The first member +is at the starting address of a structure. But a compiler is free to add +pad-bytes for alignment. So the total size of a structure may differ from the +sum of member-sizes. +A pointer to a structure points to the starting address of the structure, +there the first member is stored. + +To access a member of a structure, the structure selector$.$is used. To access +a member of a structure a pointer points to$->$is used. + +A structure can be passed by value to functions and returned by value by +functions. Allowed operators with structures are$=$and$sizeof$. + + +Declaration *crv-dtStructDef* +----------- +To declare a structure the 'structur-variable' is omitted, e.g.: > + struct myStruct { + int n; + char *name; + long counter; + }; +No variable is generated here, it's the declaration of a structure with +name myStruct. To get an object do: +$ struct myStruct ms;$ + + +Definition *crv-dtStructDecl* +---------- +A definition can be done in several ways: + + - If a structure is declared already, a definition is done this way: + $struct Person pers;$ + perss is the object generated + + - Declaration and definition can be done both, e.g.: > + struct Person { + int age; + char *name; + } pers1; +< An object pers1 is generated. 'structur-variable' can be a comma- + separated list of variables, e.g.: > + struct Person { + int age; + char *name; + } pers1, pers2, pers3; +< The objects pers1, pers2 and pers3 are generated. + + Further definitions can be done via: + $struct Person pers4;$ + because a 'structure-name' was specified above. + + - Only definition, no 'struct-name' specified, e.g.: > + struct { + int age; + char *name; + } pers1; +< An object pers1 is generated. + + +Initialization *crv-dtStructInit* +-------------- +Structures can be initialized at definition time. It is allowed to initialized +less or all members of a structure. If less are initialized the remaining +elements are set to 0 automatically. + +Examples: > + struct Person { + int age; + char *name; + } pers1 = {42, "Sting"}; +<or > + struct Person pers2 = {42, "Sting"}; + + +Accessing *crv-dtStructAccess* +--------- +A member of a structure can be accessed via$.$,e.g.: > + myStruct.age = 42; + myStruct.anotherStruct.n = 3; + +A member of a structure a pointer points to can be accessed via$->$, e.g.: > + myStructPtr->age = 42; + myStructPtr->anotherStruct.n = 3; + + +------------------------------------------------------------------------------ +I.5.6 Unions *crv-dtUnions* + *crv-union* +Syntax: + $union$union-name${$ + $variables,...$ + $}$union-variable,...$;$ + + +A union is used to store objects of different data types at the same location +in memory. All members of a union have offset 0 to the start address of the +union. Enough space is allocated only for the largest member in the union. + +For members all data types are allowed, except$void$type. The member names +must be unique within a union, but the same names can be used in nested +unions. A union cannot contain instances of themselves, but can have pointers +to instances of themselves as members. + +A pointer to a union points to the starting address of the union. + +To access a member of a union, the union selector$.$is used. To access a +member of a union a pointer points to$->$is used. + +A union can be passed by value to functions and returned by value by +functions. Allowed operators with unions are$=$and$sizeof$. + + +Declaration *crv-dtUnionDef* +----------- +To declare a union the 'union-variable' is omitted, e.g.: > + union Integers { + char c; + short s; + int n; + long l; + }; +No variable is generated here, it's the declaration of a union with name +Integers. To get an object do: +$ union Integers ints;$ + + +Definition *crv-dtUnionDecl* +---------- +A definition can be done in several ways: + + - If a union is declared already, a definition is done this way: + $union Integers ints;$ + ints is the object generated + + - Declaration and definition can be done both, e.g.: > + union Integers { + char c; + short s; + int n; + long l; + } ints1; +< An object ints1 is generated. 'union-variable' can be a comma- + separated list of variables, e.g.: > + union Integers { + char c; + short s; + int n; + long l; + } ints1, ints2, ints3; +< The objects ints1, ints2 and ints3 are generated. + + Forther definitions can be done via: + $union Integers ints;$ + because a 'union-name' was specified above. + + - Only definition, no 'union-name' specified, e.g.: > + union { + char c; + short s; + int n; + long l; + } ints1; +< An object ints1 is generated. + + +Initialization *crv-dtUnionInit* +-------------- +Unions can be initialized at definition time, but only the first member can +be given an initializer. + +Examples: > + union Integers { + char c; + short s; + int n; + long l; + } ints1 = {'a'}; +<or > + union Integers ints2 = {'a'}; + + +Accessing *crv-dtUnionAccess* +--------- +A member of a union can be accessed via$.$,e.g.: > + myUnion.age = 42; + myUnion.anotherUnion.n = 3; + +A member of a union a pointer points to can be accessed via$->$, e.g.: > + myUnionPtr->age = 42; + myUnionPtr->anotherUnion.n = 3; + + + +------------------------------------------------------------------------------ +I.5.7 Bit-Fields *crv-dtBitFields* + +Syntax: + $type-specifier identifier:constant-expression$ + +A member of a structure or union can be declared to consist of a specified +number of bits. Such a member is called a bit-field. +A bit-field can be of type$_Bool$,$signed int$,$unsigned int$or of some other +implementation specific type. The specified number of bits for a bit-field +must be small enough to be stored in its type. + +Sequences of bit-fields are packed as tightly as possible, they are assigned +from low-order to high-order bit. +If in a sequence of bit-fields a further bit-field is specified, and this +bit-field does not fit into the remaining bits, it's implementation-specific +whether this bit-field is put into the next unit or overlaps adjacent units. + +A bit-field can be closed in two ways: + - specify a data-type !=$bit-field$, a following bit-field will be started + in a new unit at low-order bit + - specify a bit-field with size 0, a following bit-field will be started + in a new unit at low-order bit + +For padding it is possible to declare a bit-field without identifier +(e.g. :10). + +Pointers to bit-field are not possible. + +Examples: > + struct BitField { + unsigned int a:2; + unsigned int :3; // leave 3 bits free + unsigned int b:4; + unsigned int :0; // force to start new unit + + unsigned int c:4: + unsigned int c:1; + + long lng; + + unsigned int d:2; // start a new unit since the previous type is + // not a bit-field + }; +< + also possible would be > + struct BitField { + unsigend int a:2, + :3, // leave 3 bits free + b:4, + :0, // force to start new unit + + c:4, + c:1; + + long lng; + + int d:2; // start a new unit since the previous type is + // not a bit-field + }; + + +Accessing a bit-field is done this way: > + struct BitField { + unsigend int a:2, + b:3; + } bf; + + bf.a = 3; + bf.b = 0; + + + +------------------------------------------------------------------------------ +I.5.8 Enumerated Tags *crv-dtEnumerate* + *crv-enum* +Syntax: + $enum identifier{enumerator-list} declarator;$ + + +An enumeration type is a user-defined integer type. The possible values of +this type are defined in the$enumerator-list$. The elements of this list are +symbolic representations of constant integers. +Each element of the$enumerator-list$gets the value of the previous plus 1. +The first element gets the value 0. Alternatively values can be assigned to +the elements. + +All this could be achieved by using$#define$too. The advantage of enumeration +types is that debuggers can view values of enumeration type objects +symbolically. + + +Examples: + $enum color {red, yellow, green};$ + + $color$is a new integer type that can have the values$red$(=0),$yellow$(=1) + and$green$(=2). + +Assignment can be done this way: > + color col; + col = red; + +To assign values to the constants do: + $enum color {red=10, yellow, green=20, white};$ + + $color$is a new integer type that can have the values$red$(=10),$yellow$ + (=11),$green$(=20) and$white$(=21). + + + +------------------------------------------------------------------------------ +I.5.9 Strings *crv-dtStrings* + +In C a string is an array of characters encapsulated in double quotes. At +the end of the string an end-of-string (0x00} is appended. + +Example: > + char strng[] = "this is a string"; + + + +------------------------------------------------------------------------------ +I.5.10 Type Definitions *crv-dtTypeDef* + +A type definition is used to define a type synonym for a data type. +Type definitions are just aliases. The compiler replaces a type definition +by its assigned type. + +Type definitions can apply to variables or functions. + +Type definitions provide: + - It is possible to replace a lengthy and/or confusing type definition + by an expressive one. + - Type definitions can simplify the process of changing the type of + variables. Example: + $typedef short coordinate;$ + If you notice that$short$is too small for your needs, simply change it: + $typedef long coordinate;$ + and all variables of the type$coordinate$will have the new type$long$. + +Example for data type: > + typedef int * pointerToInt; + + pointerToInt iPtr; // is identical to: int *iPtr; + +Example for function: > + typedef int calculate(int a, int b); // function returns int, and gets + // two ints + calculate sum; // declarate functions + calculate dif; + + int sum(int a, int b) // definition: parameters and return type + { // must be according to the typedef + return a + b; + } + + int dif(int a, int b) + { + return a - b; + } + + + +------------------------------------------------------------------------------ +I.5.11 Storage Classes *crv-dtStorageClasses* + +A storage class defines the scope and lifetime of a variable or function. + see |crv-gloScope|, |crv-gloLifetime| + + Storage Class | + Specifier | Description + ---------------+------------------------------------------------------------ + $ auto $| default, local variable has local lifetime + $ static $| local variable, but maintained during program execution + $ extern $| indicates that a variable is defined outside of the current + | file, no variable is created by this + $ register $| request to access variable as fast as possible (normally + | this means to store an object in a CPU register) + $ typedef $| creates an alias name for a basic or derived data type + none, in | a global variable is defined + file scope | + + + +$auto$ *crv-auto* +------ +The$auto$class specifies a local variable with local lifetime. The storage of +a variable is created upon entry to the block defining the variable, and is +destroyed when exiting the block. + +The contents of a new defined$auto$object is undefined. + +This class can only be declared at the beginning of a block { ... }. +If no storage class if given, this is the default. + +Example: > + int main(void) + { + int a; // auto can be omitted, it's the default + auto int b; + auto long c = 10L; // initializer can be used + + .... + } + + +$static$ *crv-static* +-------- +The$static$class specifies that an object is maintained during the whole +program execution, but it's accessable only within its scope (block or file). +Several objects with the same identifier can co-exist, as long as they have +different scopes. + +A$static$object can be declared anywhere a declaration is allowed. + +The contents of a new$static$object is initialized, arithmetic members are +set to 0, pointer members are set to NULL. If an initializer is given, the +object is initialized only once at program start. Its contents is preserved +after leaving object's scope. + +Example: > + int TestFunction () + { + static int b; // initialized with 0 automatically + static long c = 10L; // initializer can be used + + if (c == 10L) + { + b++; + c++; + } + .... // next time calling b will be 1 and c will be 11 + } + + +$register$ *crv-register* +---------- +The$register$class suggests the compiler to minimize access time for +a variable. Normally this means to assign the value to a register. +The compiler is free to do so or not. +The lifetime is the same as for$auto$. + +The$register$class is the only storage class specifier that can +be used for function parameters too. + +Example: > + int TestFunction (register int a) + { + register int b; + ... + } + + +$extern$ *crv-extern* +-------- +Using$extern$in a declaration brings the named object into the current scope, +the object must be a global one. This is used to access objects that are +defined out of the current file (linkage ->|crv-gloLinkage|). + +No new variable is generated, it is just a link to an existing one. + +Example: > + File 1: File 2: + ------- ------- + int globVar2 = 42; extern int globVar2; + + int main(void) void TestFunc(void) + { { + .... globVar2 = 3; + } ... + } + + +$typedef$ *crv-typedef* +--------- +The$typedef$is used to create an alias for a basic or derived (array, struct, +union) data type. +Actually$typedef$isn't a real storage class, but in standard C it is defined +to be one. +No new variable is generated. +For further information see |crv-dtTypeDef|. + + +Global Variable +--------------- +A global variable is defined when the definition is within file scope and +no storage class specifier is given. + +A global object is initialized, arithmetic members are set to 0, pointer +members are set to null pointer, in unions the first named member is +initialized according to this rules. An initializer can be given. + +To access a global variable from outside of its scope, declare this +variable with$extern$class in the new scope. + +Example: > + File 1: File 2: + ------- ------- + int globVar; extern int globVar2; + + int globVar2 = 42; + + int main(void) void TestFunc(void) + { { + .... globVar2 = 3; + } ... + } + + +------------------------------------------------------------------------------ +I.5.12 Qualifiers *crv-dtQualifiers* + +The type qualifiers allow to set further attributes of data types. + + Type Qualifier | Description + ----------------+------------------------------------------------------------ + $ const $| no write access to a variable + $ restrict $| only for pointers: gives compiler better possibilities for + | optimizations + $ volatile $| disable compiler optimization for a variable + + + +$const$ *crv-const* +------- +The$const$type qualifier is used to qualify an object as not modifiable. This +means no write access is allowed to this object after initialization. +The$const$qualifier can be used for any data type and together with$volatile$. + +When$const$is used to qualify an aggregate type (array, struct, union) all +members are$const$. When$const$is used to qualify a member of an aggregate +only that member is$const$. + +NOTE: Attempting to change a$const$object using a pointer to a non-$const$ +object causes unpredictable behavior. + +Example: > + const a = 5; // a = 5 and a is not modifiable + + const struct Test { + int b; + char *title; + } test; // all members of test are const + + const int *ptr; // pointer to a constant integer type + // pointer is allowed to change, contents not + + int *const ptr; // constant pointer; pointer is not allowed to change + // contents is allowed to change + + const int *const ptr; // both pointer and contents are not allowed + // to change + + +$restrict$ *crv-restrict* +---------- +The$restrict$qualifier can only be used for pointers. It indicates that the +compiler is allowed to make optimizations when dealing with this pointer. + +Normally compilers can do very less optimizations to pointers because the +compiler cannot determine whether or not two pointers point to the same +object. So the compiler must suppress various optimizations. + +The user guarantees that none of the$restrict$qualified pointers do +point to the same object. So the compiler can do further optimizations +for these pointers. + + +$volatile$ *crv-volatile* +---------- +The$volatile$qualifier indicates that the value of an object can possibly be +changed outside of compiler's control (e.g. changes done by other processes, +hardware registers of mikrocontrollers,...). The$volatile$qualifier forces +the compiler to take this into account. The compiler must access the object +always from memory and most optimizations can't be done. + +The$volatile$qualifier can be used for any data type and together with$const$ +qualifier. +When$volatile$is used to qualify an aggregate type (array, struct, union) all +members are$volatile$. When$volatile$is used to qualify a member of an +aggregate only that member is$volatile$. + +Example: > + volatile int a; + + int main(void) + { + .... + } + + +Hint: When type casting a volatile variable, the volatile qualifier will be + lost if it is omitted in the type cast operator. + +Example: > + volatile int ptrA; + long ptrB; + + ... + + ptrA = (int *)ptrB; // ATTENTION: after this, ptrA is no + // longer volatile! + + ptrA = (volatile int *)ptrB; // ptrA is still volatile + + + + + + +------------------------------------------------------------------------------ +I.5.13 Pointers *crv-dtPointers* + +A pointer contains the address of a variable of stated type, function or +memory area. + +A pointer can have a special value indicating that the pointer points to +nowhere. Such a pointer is called null pointer, its value is NULL. +A pointer of type$void$can be used to point to an object of any type. +A pointer can point to pointers. + +A pointer is declared using the$*$punctuator. The operator$*$is used to +dereference a pointer in order to have access to the contents of the object +the pointer points to. + + +I.5.13.1 Variables *crv-dtPtrVars* +------------------- +To assign the address of a variable to a pointer the address operator$&$is +used. To dereference the$*$operator is used. + +Example simple pointer: > + int n = 3; + int *ptr; // define pointer of type int + + ptr = &n; // pointer points to n + *ptr = 4; // assign object pointer points to value 4 (=> n=4) + +Example pointer to pointer: > + int n = 3; + int *ptr1; // pointer to int + int **ptr2; // pointer to pointer to int + + ptr1 = &n; // pointer ptr1 points to int n + ptr2 = &ptr1; // pointer ptr2 points to pointer to int n + **ptr2 = 4; // dereference pointer to pointer and assign 4 (n = 4) + +A pointer can be set to a fix address this way (not standard C): > + int *ptr; + + ptr = (int *)42000; + + +Pointer and Arrays +------------------ +Example pointer to array: > + int n[2]; + int *ptr; + + ptr = &n[0]; + ptr = n; // is equivalent to ptr = &n[0] + +Example array of pointers: > + int *ptrs[3]; // array of pointers to int + int n1 = 1, n2 = 2, n3 = 3; + + ptrs[0] = &n1; + ptrs[1] = &n2; + ptrs[2] = ptrs[0]; + + +Pointer to String +----------------- +A sequence of characters encapsulated with double quotes is a pointer to +const character. +Example: > + char *ptr; + + ptr = "string"; + + + +I.5.13.2 Functions *crv-dtPtrFuncs* +------------------- +A pointer can point to a function and the function can be called via pointer. + +A function pointer is defined in a similar way as a function prototype, the +function name is replaced with$(*pointer-name)$. + +Example: > + int (*funcPtr)(int a, int b); // define a function pointer "funcPtr" + + funcPtr = anyFunction; // assign function to pointer + + c = funcPtr(2, 3); // call via function pointer + + +Example: > + int sum(int a, int b) + { + return a + b; + } + + + int (*funcPtr)(int a, int b); // define a function pointer + + int main(void) + { + int a; + + funcPtr = sum; // assign function to pointer + + a = funcPtr(2, 3); // same as a = sum(2, 3); + + printf("%d\n", a); // 5 is printed + } + + +Example, call function at absolut address: > + + // call a function of type int Func(int nNumOf) + // located at address 0x42000 + + // typedefs make usage of function pointers a little bit clearer + + typedef int (*FuncPtr)( int nNumOf ); + + + int main(void) + { + FuncPtr func1; + + ... + + func1 = (FuncPtr)0x42000; // assign address to function pointer + + result = func1( n ); // call function func1 points to + } + + + + +I.5.13.3 Arithmetics *crv-dtPtrArithmetics* +--------------------- + +Some operators are allowed to be used on pointers. + + +Relational Operators +-------------------- +The relational operators$==$,$!=$,$>$,$<$,$>=$,$<=$are allowed if both +operands are pointers of the same type and both pointers point to an element +of the same array or to the first element after that array. + +The operators$==$and$!=$are allowed in any case if one of the operands is a +null pointer (NULL). + + +Negation +-------- +The logic negation$!$is allowed. +The negation of a null pointer (value NULL) is an integer value 1. The +negation of a pointer not equal NULL is an integer value 0. + + +Increasing and Decreasing +------------------------- +Increasing or decreasing of pointers of type$void$is not allowed, because the +size of the object a$void$pointer points to is unknown. + +For other pointer types it is allowed to add / subtract an integer value. +If an integer value N is added to a pointer the pointer points to the Nth +element located after the element the pointer pointed to before adding. +If an integer value N is subtracted from a pointer the pointer points to the +Nth element located before the element the pointer pointed to before +subtracting. + +Allowed operations: > + pointer + integer-value + pointer - integer-value + pointer++ + pointer-- + ++pointer + --pointer + + +Subtraction +----------- +Pointers can be subtracted. Both pointers must not be of type$void$. +Both pointers must be of the same type and must point to an element of the +same array or to the first element after that array. + +The operation$pointer1 - pointer2$returns the number of elements separating +them (negative value if pointer1 < pointer2). + + +Assignments +----------- +Assignments of pointers are of course allowed. The pointers must be of the +same type (if needed a type cast is to be done). + +Compound assignments are allowed as long as the requirements for increasing, +decreasing and subtracting are fulfilled. + +Allowed assignments: > + pointer1 = pointer2 + pointer += integer-value + pointer -= integer-value + pointer1 -= pointer2 + +------------------------------------------------------------------------------ +I.5.14 Type Cast *crv-dtTypeCast* + +Type cast is an operation that converts the type of an operand into another +type. There are two types of casts, explicit and implicit. + + +I.5.14.1 Explicit *crv-dtTypeCastExpl* +------------------ +The explicit type cast is done with the type cast operator$(type-name)$. +Example: > + int main(void) + { + int nVar = 42; + float fVar; + + fVar = (float)nVar; + } + + +I.5.14.2 Implicit *crv-dtTypeCastImpl* +------------------ +Implicit type casts are done by the compiler according to well defined rules. + +A compiler does an implicit type cast: + - When two or more operands of different types appear in an expression. + - When arguments are passed to a function that do not conform to the + parameters declared in a function prototype. + + +When a floating-type operand is converted to an integer, the fractional part +is discarded. + + + - If either operand is not of arithmetic type, no conversion is performed. + + - If either operand has type$long double$, the other operand is converted + to$long double$. + + - Otherwise, if either operand has type$double$, the other operand is + converted to$double$. + + - Otherwise, if either operand has type$float$, the other operand is + converted to$float$. + + - Otherwise the following rules apply: + + - If both operands have signed integer types or both operands have + unsigned integer types the operand with the type of lesser rank + is converted to the type of the operand with greater rank. + + - Otherwise, if the operand that has unsigned integer type has rank + greater or equal to the rank of the other operand, then the operand with + signed integer type is converted to the type of the operand with + unsigned integer type. + + - Otherwise, if the type of the operand with signed integer type can + represent all of the values of the type of the operand with unsigned + integer type, then the operand with unsigned integer type is converted + to the type of the operand with signed integer type. + + - Otherwise, both operands are converted to the unsigned integer type + corresponding to the type of the operand with signed integer type. + + +Ranking is $long long$>$long$>$int$>$short$>$char$>$bit-field$ + no matter whether singed or unsigned + + + +------------------------------------------------------------------------------ +I.5.15 Constants *crv-dtConstants* + +Beneath$enum$there are three categories of constants in C, they are described +below. + + +I.5.15.1 Integer *crv-dtConstInt* +----------------- + +An integer constant can be specified in decimal, hexadecimal or octal. A +suffix can be added to specify a constant's type. + +Decimal~ +To specify a decimal constant, the first digit must be a 1...9. For the +following digits the characters 0...9 are allowed. + +Hexadecimal~ +To specify a hexadecimal constant, a prefix 0x or 0X must be in front of the +hexadecimal number. For hex-numbers the characters 0...9, a-f and A-F are +allowed. + +Octal~ +To specify an octal constant the first digit must be a 0 (zero). For the +following digits the characters 0...7 are allowed. + + +Type~ +The type of an integer constant is the first of the corresponding list +in which its value can be represented: + + | | octal or hexadecimal + Suffix | decimal constant | constant + ==============+========================+======================== + none |$int $|$int$ + |$long int $|$unsigned int$ + |$long long int $|$long int$ + |$ $|$unsigned long int$ + | |$long long int$ + | |$unsigned long long int$ + -------------+------------------------+------------------------ + $u$or$U$ |$unsigned int$ |$unsigned int$ + |$unsigned long int$ |$unsigned long int$ + |$unsigned long long int$|$unsigned long long int$ + -------------+------------------------+------------------------ + $l$or$L$ |$long int$ |$long int$ + |$long long int$ |$unsigned long int$ + | |$long long int$ + | |$unsigned long long int$ + -------------+------------------------+------------------------ + both$u$or$U$|$unsigned long int$ |$unsigned long int$ + and$l$or$L$ |$unsigned long long int$|$unsigned long long int$ + -------------+------------------------+------------------------ + $ll$or$LL$ |$long long int$ |$long long int$ + | |$unsigned long long int$ + -------------+------------------------+------------------------ + both$u$or$U$ | | + and$ll$or$LL$|$unsigned long long int$|$unsigned long long int$ + -------------+------------------------+------------------------ + + +I.5.15.2 Floating-Point *crv-dtConstFloat* +------------------------ +A floating constant has a significant part that may be followed by an exponent +part and a suffix that specifies its type. + +If a floating constant has no suffix, its type is$double$. If suffix is$f$or +$F$it has type$float$. If suffix is$l$or$L$its type is$long double$. + + Example | Value | Type + -----------+---------+------------- + .0 | 0.00000 | double + 1. | 1.00000 | double + 2.23 | 2.23000 | double + 2e2 | 200.000 | double + 2.e2 | 200.000 | double + 2.0e2 | 200.000 | double + 2.0e+2 | 200.000 | double + 2.0e-2 | 0.02000 | double + 3.4f | 3.40000 | float + 3.4l | 3.40000 | long double + + + +I.5.15.3 Character *crv-dtConstChar* +------------------- +A character constant is any character from the source character set enclosed +in apostrophes. +See escape sequences (-> |crv-lngEscSeq|) for special characters. + +Examples: > + char a; + + a = 'd'; + a = '\x2F'; + + + +============================================================================== +I.6 Statements *crv-statements* + + +------------------------------------------------------------------------------ +I.6.1 if-else *crv-stIfElse* + *crv-if* *crv-else* +Syntax: $if (expr1)$ + $ statement1$ + $else$ + $ statement2$ + + +If$expr1$is not equal to 0,$statement1$is done. If$expr1$is equal to 0, +$statement2$is done. The$else$-part is optional. + + +------------------------------------------------------------------------------ +I.6.2 switch *crv-stSwitch* + *crv-switch* *crv-case* *crv-default* +Syntax: $switch (expr1) {$ + $ case constant-expression1:$ + $ statement1$ + $ ...$ + $ default:$ + $ statementN$ + $}$ + + +Both$case$and$default$-part are optional. + +If$expr1$is equal to one of the$constant-expressions$in the$case$labels, +the according $statement$is executed. The$default$-part is entered, +if$expr1$is not equal to one of the$constant-expressions$of the$case$labels. + +If a$statement$is done, the following$statements$are done until the end of +the$switch$statement is reached or a$break$is done. + +There can be several$case$labels, but only one$default$label. The order is +arbitrary. + + + +------------------------------------------------------------------------------ +I.6.3 while Loop *crv-stWhile* + *crv-while* +Syntax: $while (expr1)$ + $ statement$ + + +The$while$statement provides an iterative loop. +The loop body ($statement$) is executed as long as$expr1$is true (!=0). If +$expr1$is false (=0) the loop is finished. +The expression$expr1$is evaluated before$statement$is executed. + + +------------------------------------------------------------------------------ +I.6.4 do-while Loop *crv-stDoWhile* + *crv-do* +Syntax: $do$ + $ statement$ + $while (expr1);$ + + +The$do-while$statement provides an iterative loop. +The loop body ($statement$) is executed as long as$expr1$is true (!=0). If +$expr1$is false (=0) the loop is finished. +The expression$expr1$is evaluated after$statement$is executed (opposed to +$while$-loop). + + +------------------------------------------------------------------------------ +I.6.5 for Loop *crv-stFor* + *crv-for* +Syntax: $for (expr1; expr2; expr3)$ + $ statement$ + +The expressions$expr1$,$expr2$and$expr3$are optional. + + +The$for$statement provides an iterative loop. + +$expr1$: This expression is evaluated once before the first execution of the + loop body. Usually this is used to initialize variables used in the + loop body (e.g. loop counter). + +$expr2$: The loop body ($statement$) is executed as long as$expr2$is true + (!=0). If$expr2$is false (=0) the loop is finished. + If$expr2$is omitted, the expression is always true (infinite loop). + +$expr3$: This expression is evaluated after each iteration. + +The expression$expr2$is evaluated before$statement$is executed. + + +------------------------------------------------------------------------------ +I.6.6 break *crv-stBreak* + *crv-break* +Syntax: $break;$ + + +The$break$statement is used to immediately terminate the execution of the +enclosing$switch$,$for$,$while$or$do-while$statement. + + +------------------------------------------------------------------------------ +I.6.7 continue *crv-stContinue* + *crv-continue* +Syntax: $continue;$ + + +The$continue$statement is used to immediately jump to the end of the +enclosing$for$,$while$or$do-while$statement. + + +------------------------------------------------------------------------------ +I.6.8 goto *crv-stGoto* + *crv-goto* +Syntax: $goto identifier;$ + + +The$goto$statement causes an unconditional jump to a labeled statement +that is specified by$identifier$. The labeled statement must be in the scope +of the function containing the$goto$statement. + +A$goto$statement is not allowed to jump past any declaration of objects. +Apart from this jumping into other blocks is allowed. + + +------------------------------------------------------------------------------ +I.6.9 return *crv-stReturn* + *crv-return* +Syntax: $return expr1;$ + +$expr1$is optional + + +The$return$statement terminates execution of the current function and returns +control to its caller. If present,$expr1$is evaluated and its value is +returned to the calling function. If the type of$expr1$is not the same as +the type of the function, implicit type cast is done. + +A$return$statement can appear anywhere in a function, several$return$ +statements are allowed. + +For functions of type$void$either a return without$expr1$must be given or +no$return$statement ($return;$and the enclosing$}$of the function are treated +as the same). + + +------------------------------------------------------------------------------ +I.6.10 Null Statement *crv-stNull* + +Syntax: $;$ + + +A null statement performs no operation. A null statement is used in situations +where the grammar of C requires a statement, but the program needs no +operation. + +Usage: + - supply an empty loop body + Example: > + char *strngPtr; + + while (*stngPtr++ != 'a') // search first 'a' in string + ; +< + - set a label just before the closing$}$ + Example: > + .... + } + end_loop: ; + } + + + + +============================================================================== +I.7 Functions *crv-functions* + + +------------------------------------------------------------------------------ +I.7.1 Definition *crv-fuDefinition* + + $return-type function-name(parameter-list, ...) {$ + $ statement...$ + $}$ + + $return-type$ type of value returned by function + $function-name$ name of function + $parameter-list$ list of parameters passed to function + + +The$return-type$is the type the function returns. It can be any type except +array types or function types. If no value is returned,$void$must be used. +If$return-type$is omitted,$int$is assumed. + +The$function-name$is the identifier under that a function can be called +(see |crv-gloIdentifier| for valid names). + +The$parameter-list$specifies the parameters a function expects when called. +A function can have no parameter, a specific number of parameters or +a variable number of parameters. + + - No Parameter + -------------- + $parameter-list$must be$void$ + Example: > + int Func(void) + { + ... + return 0; + } +< + - One or More Parameters + ------------------------ + $parameter-list$is a comma separated list of parameter specifications. + Each parameter must be specified this way: $type-name identifier$ + $type-name$ : type of the parameter, if omitted$int$is used + $identifier$: identifier under which this parameter can be referenced + within the function + Example: > + int Func(char ch, int cntr) + { + if ( (ch == 'q') || (cntr == 42) ) + exit(0); + + return 0; + } +< + - Variable Number of Parameters *crv-fuDefVarPara* + ------------------------------- + $parameter-list$is a comma separated list of parameter specifications + ending with an ellipsis ($,...$). + Functions declared in$<stdarg.h>$can be used to access arguments. + + Example: > + #include <stdarg.h> + #include <stdio.h> + + + void Func(int numOfArgs, ...) + { + int n; + va_list ap; + + va_start(ap, numOfArgs); // initialize + + for (n = 0; n < numOfArgs; n++) + printf("%d ", va_arg(ap, int)); // get next argument, type is int + + printf("\n"); + + va_end(ap); // finish + } + + + int main(void) + { + Func(1, 100); // output is 100 + Func(2, 100, 101); // output is 100 101 + Func(3, 100, 101, 102); // output is 100 101 102 + } +< + +A parameter can be of any type. But parameters of array type or function type +are converted automatically to pointers. +Example: > + #include <stdio.h> + + + int Func2() + { + return 3; + } + + + void Func1(int n[3], int (*func)(void)) + { + n[0] = 1; + n[1] = 2; + n[2] = func(); + } + + int main(void) + { + int n[3] = {5, 5, 5}; + + Func1(n, Func2); + + printf("%d %d %d\n", n[0], n[1], n[2]); // output is 1 2 3 + + } +< + +The only allowed storage class for a parameter is$register$. +All kinds of type qualifiers are allowed for parameters. + +Arguments are passed by value, that means that a function receives a copy +of the argument's value. +The order of evaluation of arguments is not specified. + + + +------------------------------------------------------------------------------ +I.7.2 Prototype *crv-fuPrototype* + + $return-type function-name(parameter-list, ...);$ + + +If a function is used before it's defined then it must be prototyped, so +that the compiler knows about return type and parameter types of the function, +else$int$is assumed for return type and parameter types. + +A prototype is identical to the function header with the addition of an +ending$;$. Function prototypes need not use parameter identifiers. Only the +types are required. + +Normally prototyping occurs at the beginning of a source code file or in a +header file. + + +Example: > + int Func(char ch); + + + int main(void) + { + if (Func1('q') == 2) + { + .... + } + } + + + int Func(char ch) + { + ... + } +< + + +------------------------------------------------------------------------------ +I.7.3 Conversion *crv-fuConversion* + + +If a function is called the arguments must be of the same types as specified +in prototype. If not, conversions are done. + +Example: > + void Func(int n, char c, long l); + + int main(void) + { + char chr; + long a; + int b; + + ... + + Func(chr, a, b); // chr is converted to type int + // a is converted to type char + // b is converted to type long + } +< + +If no prototype is in scope when calling a function the following conversions +are done on the arguments: + - An argument of type$float$is converted to type$double$. + - If an$int$can represent all values of the original type, the value is + converted to an$int$. Otherwise it is converted to an$unsigned int$. + For most compilers this means: an argument of type$char$,$unsigned char$, + $short$,$unsigned short$is converted to type$int$. + +This is called "argument promotion". + +No other conversions are performed on arguments. + + +------------------------------------------------------------------------------ +I.7.4 Storage Classes *crv-fuStorageClasses* + +Implicitly functions do have the storage class$extern$. To limit the scope of +a function to a file$static$can be used. + +Example$extern$: > + File 1 File 2 + ------ ------ + + int GetSolution(void) extern int GetSolution(void); + { + return 42; + } void Func(void) + { + if (GetSolution() == 42) + int main(void) { + { ... + if (GetSolution() != 42) } + { } + ... + } + } +< + +Example$static$: > + File + ---- + + static int GetSolution(void) // can only be referenced within same file + { + return 42; + } + + + int main(void) + { + if (GetSolution() == 42) + { + ... + } + } +< + + +------------------------------------------------------------------------------ +I.7.5 Specifier *crv-fuSpecifier* + *crv-inline* + +A function declared with an$inline$specifier is an inline function. This +suggests that calls to the function be as fast as possible. The extend to +which this suggestion is taken into account is implementation specific. + +Normally$inline$means that the call to the function is replaced by the +function body. As a result of this there is no overhead for calling, but at +the expense of code size, since each call of the inline function is replaced +by it's function body. + +For$main()$the$inline$specifier is not allowed. + +Example: > + + inline int Func(void) + { + ... + return 42; + } + + + int main(void) + { + int a; + + a = Func(); + ... + } +< + + + +------------------------------------------------------------------------------ +I.7.6 main() *crv-fuMain* + +A program begins by calling the$main()$function and ends by exiting +the$main()$function. There is no prototype required for$main()$. + +$main()$can be defined in two ways, either with no parameter + +$ int main(void)$ +$ {$ +$ statements$ +$ }$ + +or with two parameters + +$ int main(int argc, char *argv[])$ +$ {$ +$ statements$ +$ }$ + +The return type is type$int$. + +The parameters do not have to be named$argc$and$argv$, but it is a common way +to do so. + +Parameter$argc$is a nonnegative integer. If the value of$argc$is greater than +zero, the string pointed to by$argv[0]$is the program name. If the value +of$argc$is greater than one, the strings pointed to by$argv[1]$through +$argv[argc - 1]$represent the program parameters. + + + +============================================================================== +I.8 Preprocessor *crv-preprocessor* + +A preprocessor is the first pass of a compiler. It does perform macro +substitution, inclusion of files, conditional compilation and provides the +ability to pass control directives to the compiler. + +A C-preprocessor directive is invoked by a$#$. Opposed to a C-statement a +C-preprocessor directive is NOT terminated by a semicolon ($;$), instead of +it is terminated by the new-line. To span a directive over several lines +the "line-escape"$\$can be used (see |crv-lngEscSeq|). +Example: > + #define MEAS_CYCLES (3 \ + + \ + 1) +< +is synonymical to: > + #define MEAS_CYCLES (3 + 1) + + +A C-preprocessor directive can be placed anywhere in a source file. The +directive is active from the line of invocation up to the end of source file. + + +In the following sections possible preprocessor directives and preprocessor +operators are described. + + + +------------------------------------------------------------------------------ +I.8.1 Macros *crv-preMacros* + +A macro is an identifier that is equated to a text or symbolic expression +to which it is to be expanded by the preprocessor. + + *crv-preMacObj* *crv-preMacFunc* +There are two types of macros: macros without parameters, they are called +object-like macros and macros with parameters, they are called function-like +macros. + +When using a macro each subsequent occurrence of the macro$identifier$within +source-file is replaced by its$replacement-list$, unless the macro occurs +inside of a comment, a literal string or a character constant. + +A macro definition lasts until end of the source-file or until a corresponding +$#undef$is encountered. + +Macros can be nested. + + +NOTE: It is not a good programming style to specify macro arguments that +use side effects. Macro parameters can be used several times within a macro, +that can cause unexpected behaviour. +Example: > + #define MIN(a, b) ( (a < b) ? a : b ) + + MIN(val1++, val2) +< + would be replaced: > + ( (val1++ < val2) ? val1++ : val2 ) + + + +I.8.1.1 Definition #define *crv-preMacDef* +--------------------------- + *crv-#define* +Syntax Object-Like Macro: + $#define identifier replacement-list newline$ + +Syntax Function-Like Macro: + $#define identifier(identifier-list) replacement-list newline$ + + +Example of an object-like macro: > + #define CONST_ADD 42 + #define FOREVER for(;;) + + int main(void) + { + int a = 0; + + FOREVER + { + a += CONST_ADD; + ... + } + } +< +Example of a function-like macro: > + #define MIN(a, b) ( (a < b) ? a : b ) + + int main(void) + { + int x1, x2, x; + + x1 = 2; + x2 = 5; + + x = MIN(x1, x2); + } +< +Example of a nested macro: > + #define CONST1 ( 35 + CONST2 ) + #define COSNT2 7 +< + + +I.8.1.2 Cancellation #undef *crv-preMacCancel* +---------------------------- +Syntax: $#undef identifier newline$ *crv-#undef* + +A macro specified by$identifier$is no longer a macro name. If$identifier$is +currently no macro, this directive is ignored. + +Example: > + #define CONST 5 + + int main(void) + { + ... + a = CONST; + ... + + #undef CONST + + a = CONST; // will cause an error at compilation time + } +< + + +I.8.1.3 # Operator *crv-preMac#Operator* +------------------- + *crv-#* +The preprocessor operator$#$converts an argument of a function-like macro to a +string literal. + +Example: > + #define PRINT1(var) printf("Value of "#var" is: %d\n", var) + #define PRINT2(var) printf("Value of %s is: %d\n", #var, var) + + int main(void) + { + int a = 2; + int b = 3; + + PRINT1(a); // prints: Value of a is: 2 + PRINT2(b); // prints: Value of b is: 3 + } + + + +I.8.1.4 ## Operator *crv-preMac##Operator* +-------------------- + *crv-##* +The preprocessor operator$##$concatenates two tokens. + +Example: > + #define PRINT(prefix, postfix) printf("Value is: %d\n", prefix ## postfix) + + int main(void) + { + int varCar = 2; + int varHouse = 3; + + PRINT(var, Car); // prints: Value is: 2 + PRINT(var, House); // prints: Value is: 3 + } + + + +I.8.1.5 Predefined Macros *crv-preMacPredefined* +-------------------------- + +There is a set of predefined macro names. They are not allowed to be changed. + *crv-__DATA__* +$__DATA__$ This macro is evaluated to a string literal representing the + date when compilation of the current source-file began. Its + form is "Mmm dd yyyy". The names of the months are the same as + those generated by the$asctime()$function. + *crv-__FILE__* +$__FILE__$ This macro is evaluated to a string literal representing the + name of the current source-file. + *crv-__LINE__* +$__LINE__$ This macro is evaluated to a decimal constant representing the + current line number. + *crv-__STDC__* +$__STDC__$ The integer constant 1. Used to indicate if this is a standard + C compiler. + +$__STDC_HOSTED__$ *crv-__STDC_HOSTED__* + This macro is evaluated to an integer constant value. If 1 + the compiler is hosted, if 0 it is not. + +$__STDC_VERSION__$ *crv-__STDC_VERSION__* + This macro is evaluated to a$long int$value that belongs to the + revision of the International C Standard. + *crv-__TIME__* +$__TIME__$ This macro is evaluated to a string literal representing the + time when compilation of the current source-file began. Its + form is "hh:mm:ss", the same as what is generated the$asctime()$ + function. + + +Furthermore the compiler conditionally provides the following macros: + +$__STDC_IEC_559__$ *crv-__STDC_IEC_559__* + The integer constant 1. Used to indicate if this C compiler is + conform to the floating-point standard IEC 60559. + +$__STDC_IEC_559_COMPLEX__$ *crv-__STDC_IEC_559_COMPLEX__* + The integer constant 1. Used to indicate if this C compiler's + complex arithmetic is conform to the floating-point standard + IEC 60559. + +$__STDC_ISO_10646__$ *crv-__STDC_ISO10646__* + This macro is evaluated to a$long int$constant value of the + form yyyymm. Its intention is to indicate that values of + $wchar_t$are the coded representations of the characters defined + by ISO/IEC 10646. The year/month refers to the ISO/IEC 10646 + including amendments and corrections this implementation is + conform to. + + + +------------------------------------------------------------------------------ +I.8.2 Conditional Compilation *crv-preConditional* + +There are preprocessor directives that allow to control which part of a +source-code is to be or is not to be translated (conditional compilation). + + +I.8.2.1 defined Operator *crv-preCondDefined* +------------------------- + *crv-defined* +Syntax: $defined identifier$ + or$defined (identifier)$ + + +The$defined$operator evaluates to 1 if$identifier$is defined, else it +evaluates to 0.$identifier$is a macro name. + +$defined$operators can be combined in any logical expression using logical +operators (see |crv-opLogical|). +$defined$is allowed to be used in the expression of an$#if$or$#elif$directive. + + +Example: > + #if defined(MACRO1) || (defined(MACRO2) && !defined(MACRO3)) + ... + #endif + + +I.8.2.2 #if Directive *crv-preCondIf* +---------------------- + *crv-#if* +Syntax: $#if constant-expression newline$ + + +This preprocessor directive checks whether the constant expression evaluates +to nonzero. If so, the source-code between$#if$and the corresponding$#endif$, +$#else$or$#elif$is passed to compiler, else it's skipped. + +The constant expression may be a$defined$operator, a macro name or any +constant integer expression. Not allowed are type-casts, keywords or +expressions that need memory ($++$,$--$...). +If a macro name used in the constant expression does not exist, it's treated +as zero. + +Example: > + #if defined(MACRO1) || (defined(MACRO2) && !defined(MACRO3)) + ... + #endif + + #if (CONST_VALUE + 5 == 8) + ... // its value is 8 + #else + ... // its value is not 8 + #endif + + + +I.8.2.3 #ifdef Directive *crv-preCondIfdef* +------------------------- + *crv-#ifdef* +Syntax: $#ifdef identifier newline$ + + +This preprocessor directive checks whether the identifier is currently +defined. If so, the source-code between$#ifdef$and the corresponding$#endif$, +$#else$or$#elif$is passed to compiler, else it's skipped. + +Example: > + #define DEBUG 1 + + #ifdef DEBUG + ... // that is passed to the compiler + #endif + + + +I.8.2.4 #ifndef Directive *crv-preCondIfndef* +-------------------------- + *crv-#ifndef* +Syntax: $#ifndef identifier newline$ + + +This preprocessor directive checks whether the identifier is currently not +defined. If so, the source-code between$#ifndef$and the corresponding$#endif$, +$#else$or$#elif$is passed to compiler, else it's skipped. + +Example: > + #define DEBUG 1 + + #ifndef DEBUG + ... // that is not passed to the compiler + #endif + + + +I.8.2.5 #else Directive *crv-preCondElse* +------------------------ + *crv-#else* +Syntax: $#else newline$ + + +This directive is used together with$#if$,$#ifdef$or$#ifndef$. If the "if" +does not evaluate to nonzero, the source code between the matching$else$and +the$endif$is passed to compiler. + +Example: > + #define DEBUG 1 + + #ifndef DEBUG + ... // that is not passed to the compiler + #else + ... // that is passed to the compiler + #endif + + + +I.8.2.6 #elif Directive *crv-preCondElif* +------------------------ + *crv-#elif* +Syntax: $#elif constant-expression newline$ + + +This directive provides an else-if statement. It can be used together +with$#if$,$#ifdef$,$#ifndef$or another$#elif$. If the corresponding "if" does +not evaluate to nonzero the$#elif$'s constant expression is tested to be +nonzero. If so, the source-code between$#elif$and the matching$#else$,$#elif$ +or$#endif$is passed to the compiler, else not. + +See |crv-preCondIf| for further information on the constant expression. + +Example: > + #if (CONST_VALUE + 5 == 8) + ... // its value is 8 + #elif (CONST_VALUE + 5 == 9) + ... // its value is 9 + #endif + + + +I.8.2.7 #endif Directive *crv-preCondEndif* +------------------------- + *crv-#endif* +Syntax: $#endif newline$ + + +This directive is used to finish one of this directives:$#if$,$#ifdef$, +$#ifndef$,$elif$or$else$. + + +Example: > + #ifdef DEBUG + ... + #endif + + + +------------------------------------------------------------------------------ +I.8.3 File Inclusion #include *crv-preSourceInc* + *crv-#include* +Syntax: $#include "filename" newline$ (1) + $#include <filename> newline$ (2) + $#include macro-name newline$ (3) + + +This preprocessor directive causes the replacement of that directive by the +entire contents of the file specified by$filename$. + +Files enclosed in <...> are searched in an implementation-defined manner. +Files enclosed in quotes "..." are searched in an implementation-defined +manner too, if a file is not found it is searched in the same way like +files enclosed in <...>. + +In general, form (1) is used to include user files whereas form (2) is used +to include standard library files. + +This directive does support macro replacement (form (3)). + +Nesting is allowed, an included file may itself contain$#include$directives. +But nesting easy leads to the situation that files are included several times, +which would waste time and may cause compilation errors. There is a standard +way to prevent that a file is included twice due to nesting. It is called +"wrapper #ifndef". Do the following in included files to avoid processing +them twice: > + // file foo.h + + #ifndef _FOO_H_ + #define _FOO_H_ + + ... the entire file + + #endif // #endif of _FOO_H_ + + +Example: > + #include <stdio.h> + + #include "galer.h" + + + #define HEADER_FILE "datatype.h" + + #include HEADER_FILE + + + + +------------------------------------------------------------------------------ +I.8.4 Line Control #line *crv-preLine* + *crv-#line* +Syntax: $#line digit-sequence newline$ (1) + $#line digit-sequence "filename" newline$ (2) + $#line macro-names newline$ (3) + + +This preprocessor directive allows to change the current line number and/or +the name of the current source-code file. + +The$#line$directive gives the next line in source-code a new line-number. +The line numbers of the subsequent lines are derived from this number by +incrementing for each new line. +The new line-number is specified by$digit-sequence$. Line numbers must be +in the range of 1 to 2147483647. + +Furthermore for the current source-code file a new filename can be specified +($filename$). + +Form (1) can be used to set a new line number. Form (2) can be used to set +both, a new line number and a new filename. +In form (3) the macro-names are expanded, the result must match either +form (1) or (2). Its then processed appropriate. + +The$#line$directive effects the predefined macros$#__LINE__$and$#__FILE__$. + +Example: > + #line 1000 "GALer.c" +or > + #define NEW_LINE_NUMBER 1000 + #define SOURCE "GALer.c" + + #line NEW_LINE_NUMBER SOURCE + printf("%d %s\n", __LINE__, __FILE__); // result is: 1000 GALer.c + + + +------------------------------------------------------------------------------ +I.8.5 Error Directive #error *crv-preError* + *crv-#error* +Syntax: $#error message newline$ + + $message$is optional + + +This preprocessor directive causes the compiler to print a diagnostic message +that includes$message$and cancel compilation. + +Example: > + #if defined UNIX + ... + #elif defined LINUX + ... + #elif + #error Error: no system specified + #endif +< + If neither UNIX nor LINUX is defined, the compiler prints an error message: + "Error: no system specified" and cancels compilation. + + + +------------------------------------------------------------------------------ +I.8.6 Pragma Directive #pragma *crv-prePragma* + *crv-#pragma* +Syntax: $#pragma directive newline$ + + +This preprocessor directive provides further control over the compiler. Which +$#pragma$directives an implementation provides is implementation specific. +If a$#pragma$directive is not known by the implementation, it is ignored. + + +Example: > + #pragma Int16 // use 16 bit integer for this file + + #pragma DISABLE_WARNING_32 // disable warning 32 for this file + ... do stuff that would cause a warning 32 + #pragma ENABLE_WARNING_32 + + + + +------------------------------------------------------------------------------ +I.8.7 Null Directive # *crv-preNull* + +Syntax: $# newline$ + +The preprocessor directive of the form$# newline$has no effect. + + + + + + +============================================================================== +Chapter II STANDARD C LIBRARY *crv-stdCLib* +============================================================================== + +The C language provides no built-in facilities for performing such common +operations as input/output, memory management, string manipulation, and the +like. Instead, these facilities are defined in a standard C library which can +be linked to program. +Subject of this chapter is the standard C library as specified by the ISO C +standard. + + +============================================================================== +II.1 Standard Headers *crv-libHeaders* + +Below is an alphabetically sorted list of all header files of the standard C +library. + + Header | Short Description + --------------+----------------------------------------------------------- + $<assert.h> $| diagnostics.............................|crv-libAssertH| + $<complex.h> $| complex arithmetic......................|crv-libComplexH| + $<ctype.h> $| character handling......................|crv-libCtypeH| + $<errno.h> $| error codes.............................|crv-libErrnoH| + $<fenv.h> $| floating point environment..............|crv-libFenvH| + $<float.h> $| characteristics of floating point types.|crv-libFloatH| + $<inttypes.h>$| format conversion of integer types......|crv-libInttypesH| + $<iso646.h> $| alternative spelling....................|crv-libIso646H| + $<limits.h> $| sizes of integer types..................|crv-libLimitsH| + $<local.h> $| localization............................|crv-libLocalH| + $<math.h> $| mathematics.............................|crv-libMathH| + $<setjmp.h> $| nonlocal jumps..........................|crv-libSetjmpH| + $<signal.h> $| signal handling.........................|crv-libSignalH| + $<stdarg.h> $| variable arguments......................|crv-libStdargH| + $<stdbool.h> $| boolean type and values.................|crv-libStdboolH| + $<stddef.h> $| common definitions......................|crv-libStddefH| + $<stdint.h> $| integer types...........................|crv-libStdintH| + $<stdio.h> $| input / output..........................|crv-libStdioH| + $<stdlib.h> $| general utilities.......................|crv-libStdlibH| + $<string.h> $| string handling.........................|crv-libStringH| + $<tgmath.h> $| type-generic math.......................|crv-libTgmathH| + $<time.h> $| date and time...........................|crv-libTimeH| + $<wchar.h> $| extended multibyte and wide.............|crv-libWcharH| + | character utilities + $<wctype.h> $| wide character classification and.......|crv-libWctypeH| + | mapping utilities + + + +============================================================================== +II.2 <assert.h> Diagnostics *crv-libAssertH* + + Quicklink: + $assert()$ Macro |crv-assert| + $NDEBUG$ Macro |crv-NDEBUG| + + +assert() Macro *crv-assert* *crv-NDEBUG* +-------------- +Synopsis~ + $#include <assert.h>$ + $void assert (int expression);$ + +Return~ + none + +Description~ +The macro$assert()$tests the value of$expression$. If it is false (zero), +the$assert()$macro writes the following information on the standard error +stream: + - text of argument + - name of source file + - line number + - name of the enclosing function +The format of output is implementation-defined. After writing this information +the program is terminated by calling the$abort()$function. + +If the macro$NDEBUG$is defined before including$<assert.h>$,$assert()$is +defined as follows: + $#define assert(ignore) ((void)0)$ +This means that the macro has no effect,$expression$is even not evaluated. + +Note: The assert facility is designed for detecting internal inconsistency; +it is not suitable for reporting invalid input or improper usage by the user +of the program. + + + + +============================================================================== +II.3 <complex.h> Complex Math *crv-libComplexH* + +This header file defines macros and declares functions that allow to do +complex arithmetic. + +Quicklink: + $_Complex_I$ Macro |crv-_Complex_I| + $_Imaginary_I$ Macro |crv-_Imaginary_I| + $cabs()$ Func |crv-cabs| + $cabsf()$ Func |crv-cabsf| + $cabsl()$ Func |crv-cabsl| + $cacos()$ Func |crv-cacos| + $cacosf()$ Func |crv-cacosf| + $cacosl()$ Func |crv-cacosl| + $casin()$ Func |crv-casin| + $casinf()$ Func |crv-casinf| + $casinl()$ Func |crv-casinl| + $catan()$ Func |crv-catan| + $catanf()$ Func |crv-catanf| + $catanl()$ Func |crv-catanl| + $cacosh()$ Func |crv-cacosh| + $cacoshf()$ Func |crv-cacoshf| + $cacoshl()$ Func |crv-cacoshl| + $carg()$ Func |crv-carg| + $cargf()$ Func |crv-cargf| + $cargl()$ Func |crv-cargl| + $casinh()$ Func |crv-casinh| + $casinhf()$ Func |crv-casinhf| + $casinhl()$ Func |crv-casinhl| + $catanh()$ Func |crv-catanh| + $catanhf()$ Func |crv-catanhf| + $catanhl()$ Func |crv-catanhl| + $ccos()$ Func |crv-ccos| + $ccosf()$ Func |crv-ccosf| + $ccosl()$ Func |crv-ccosl| + $ccosh()$ Func |crv-ccosh| + $ccoshf()$ Func |crv-ccoshf| + $ccoshl()$ Func |crv-ccoshl| + $cexp()$ Func |crv-cexp| + $cexpf()$ Func |crv-cexpf| + $cexpl()$ Func |crv-cexpl| + $cimag()$ Func |crv-cimag| + $cimagf()$ Func |crv-cimagf| + $cimagl()$ Func |crv-cimagl| + $clog()$ Func |crv-clog| + $clogf()$ Func |crv-clogf| + $clogl()$ Func |crv-clogl| + $conj()$ Func |crv-conj| + $conjf()$ Func |crv-conjf| + $conjl()$ Func |crv-conjl| + $cpow()$ Func |crv-cpow| + $cpowf()$ Func |crv-cpowf| + $cpowl()$ Func |crv-cpowl| + $cproj()$ Func |crv-cproj| + $cprojf()$ Func |crv-cprojf| + $cprojl()$ Func |crv-cprojl| + $creal()$ Func |crv-creal| + $crealf()$ Func |crv-crealf| + $creall()$ Func |crv-creall| + $csinh()$ Func |crv-csinh| + $csin()$ Func |crv-csin| + $csinf()$ Func |crv-csinf| + $csinl()$ Func |crv-csinl| + $csinh()$ Func |crv-csinh| + $csinhf()$ Func |crv-csinhf| + $csinhl()$ Func |crv-csinhl| + $csqrt()$ Func |crv-csqrt| + $csqrtf()$ Func |crv-csqrtf| + $csqrtl()$ Func |crv-csqrtl| + $ctan()$ Func |crv-ctan| + $ctanf()$ Func |crv-ctanf| + $ctanl()$ Func |crv-ctanl| + $ctanh()$ Func |crv-ctanh| + $ctanhf()$ Func |crv-ctanhf| + $ctanhl()$ Func |crv-ctanhl| + $complex$ Macro |crv-complex| + $CX_LIMITED_RANGE$ Pragma |crv-CX_LIMITED_RANGE| + $I$ Macro |crv-I| + $imaginary$ Macro |crv-imaginary| + + +------------------------------------------------------------------------------ +II.3.1 Macros *crv-libCHMac* + + +_Complex_I Macro *crv-_Complex_I* +---------------- +This macro expands to$const float _Complex$with the complex number "0+1i". + + +_Imaginary_I Macro *crv-_Imaginary_I* +------------------ +This macro is defined only if the compiler supports imaginary types. +If defined, it expands to$_Imaginary$and a constant expression of the type +$const float _Imaginary$with the value "0+1i". + + +complex Macro *crv-complex* +------------- +This macro expands to$_Complex$. + + +I Macro *crv-I* +------- +This macro either expands to$_Imaginary_I$or$_Complex_I$. If$_Imaginary_I$is +not defined$I$expands to$_Complex_I$. + + +imaginary Macro *crv-imaginary* +--------------- +This macro is defined only if the compiler supports imaginary types. +If defined, it expands to$_Imaginary$and a constant expression of the type +$const float _Imaginary$with the value "0+1i". + + + +------------------------------------------------------------------------------ +II.3.2 Pragmas *crv-libCHPrag* + + +CX_LIMITED_RANGE Pragma *crv-CX_LIMITED_RANGE* +----------------------- +Synopsis~ + $#include <complex.h>$ + $#pragma STDC CX_LIMITED_RANGE on/off-switch$ + + $on/off-switch$is$ON$,$OFF$or$DEFAULT$ + +Description~ +Complex arithmetic is problematic because of their treatment of infinities +and because of undue overflow and underflow. +If this pragma is on the compiler is informed that the usual mathematical +formulas can be used. If on, the compiler can use this formulas: + (x + iy)x(u + iv) = (xu - yv) + i(yu + xv) + + (x + iy) / ( u + iv) = [(xu + yv) + i(yu - xv)] / (u^2 + v^2) + + ----------- + | x + iy | = \| x^2 + y^2 + +When inside a compound statement, the pragma takes effect from its occurrence +until end of compound statement or until the next$CX_LIMITED_RANGE$is +encountered; at the end of a compound statement the state of the pragma is +restored to its state just before entering that compound statement. +When outside a compound statement, the pragma takes effect from its occurrence +until end of source-file or until the next$CX_LIMITED_RANGE$is encountered. +The default state of this pragma is off. + + + +------------------------------------------------------------------------------ +II.3.3 Trigonometric *crv-libCHTrig* + + +cacos() Functions *crv-cacos* *crv-cacosf* *crv-cacosl* +----------------- +Synopsis~ + $#include <complex.h>$ + $double complex cacos(double complex z);$ + $float complex cacosf(float complex z);$ + $long double complex cacosl(long double complex z);$ + +Return~ +return complex arc cosine of z in radians +Values: imaginary is unbounded, real is in the interval [0, PI] + +Description~ +These functions compute the complex arc cosine of z, with branch cuts outside +the interval [-1, +1] along real axis. + + + +casin() Functions *crv-casin* *crv-casinf* *crv-casinl* +----------------- +Synopsis~ + $#include <complex.h>$ + $double complex casin(double complex z);$ + $float complex casinf(float complex z);$ + $long double complex casinl(long double complex z);$ + +Return~ +return complex arc sine of z in radians +Range: imaginary is unbounded, real is in the interval [-PI/2, +PI/2] + +Description~ +These functions compute the complex arc sine of z, with branch cuts outside +the interval [-1, +1] along real axis + + + +catan() Functions *crv-catan* *crv-catanf* *crv-catanl* +----------------- +Synopsis~ + $#include <complex.h>$ + $double complex catan(double complex z);$ + $float complex catanf(float complex z);$ + $long double complex catanl(long double complex z);$ + +Return~ +return complex arc tangent of z in radians +Range: imaginary is unbounded, real is in the interval [-PI/2, +PI/2] + +Description~ +These functions compute the complex arc tangent of z, with branch cuts outside +the interval [-i, +i] along imaginary axis. + + + +ccos() Functions *crv-ccos* *crv-ccosf* *crv-ccosl* +---------------- +Synopsis~ + $#include <complex.h>$ + $double complex ccos(double complex z);$ + $float complex ccosf(float complex z);$ + $long double complex ccosl(long double complex z);$ + +Return~ +return complex cosine of z + +Description~ +These functions compute the complex cosine of z. +The mathematical definition of the complex cosine is: + cos(z) = 1/2 * (exp(z*i) + exp(-z*i)) + + + +csin() Functions *crv-csin* *crv-csinf* *crv-csinl* +---------------- +Synopsis~ + $#include <complex.h>$ + $double complex csin(double complex z);$ + $float complex csinf(float complex z);$ + $long double complex csinl(long double complex z);$ + +Return~ +return complex sine of z + +Description~ +These functions compute the complex sine of z. +The mathematical definition of the complex sine is: + sin(z) = 1/(2*i) * (exp(z*i) - exp(-z*i)) + + + +ctan() Functions *crv-ctan* *crv-ctanf* *crv-ctanl* +---------------- +Synopsis~ + $#include <complex.h>$ + $double complex ctan(double complex z);$ + $float complex ctanf(float complex z);$ + $long double complex ctanl(long double complex z);$ + +Return~ +return complex tangent of z + +Description~ +These functions compute the complex tangent of z. +The mathematical definition of the complex tangent is: + tan(z) = -i * (exp(z*i) - exp(-z*i)) / (exp(z*i) + exp(-z*i)) + +NOTE: The complex tangent has poles at PI/2 + 2n, where n is an integer. +$ctan()$may signal overflow if z is too close to a pole. + + + +------------------------------------------------------------------------------ +II.3.4 Hyperbolic *crv-libCHHyper* + + +cacosh() Functions *crv-cacosh* *crv-cacoshf* *crv-cacoshl* +------------------ +Synopsis~ + $#include <complex.h>$ + $double complex cacosh(double complex z);$ + $float complex cacoshf(float complex z);$ + $long double complex cacoshl(long double complex z);$ + +Return~ +return complex arc hyperbolic cosine of z +Range: real is >= 0, imaginary is [-iPI, +iPI] + +Description~ +These functions compute the complex arc hyperbolic cosine of z. +Domain: real of z >= 1 + + + +casinh() Functions *crv-casinh* *crv-casinhf* *crv-casinhl* +------------------ +Synopsis~ + $#include <complex.h>$ + $double complex casinh(double complex z);$ + $float complex casinhf(float complex z);$ + $long double complex casinhl(long double complex z);$ + +Return~ +return complex arc hyperbolic sine of z +Range: real is unbounded, imaginary is [-iPI/2, +iPI/2] + +Description~ +These functions compute the complex arc hyperbolic sine of z. +Domain: imaginary in range [-i, +i] + + + +catanh() Functions *crv-catanh* *crv-catanhf* *crv-catanhl* +------------------ +Synopsis~ + $#include <complex.h>$ + $double complex catanh(double complex z);$ + $float complex catanhf(float complex z);$ + $long double complex catanhl(long double complex z);$ + +Return~ +return complex arc hyperbolic tangent of z +Range: imaginary is unbounded, real is [-PI/2, +PI/2] + +Description~ +These functions compute the complex arc hyperbolic tangent of z. +Domain: real in range [-1, +1] + + + +ccosh() Functions *crv-ccosh* *crv-ccosfh* *crv-ccoslh* +----------------- +Synopsis~ + $#include <complex.h>$ + $double complex ccosh(double complex z);$ + $float complex ccoshf(float complex z);$ + $long double complex ccoshl(long double complex z);$ + +Return~ +return complex hyperbolic cosine of z + +Description~ +These functions compute the complex hyperbolic cosine of z. +The mathematical definition of the complex hyperbolic cosine is: + cosh(z) = 1/2 * (exp(z) + exp(-z)) + + + +csinh() Functions *crv-csinh* *crv-csinhf* *crv-csinhl* +----------------- +Synopsis~ + $#include <complex.h>$ + $double complex csinh(double complex z);$ + $float complex csinhf(float complex z);$ + $long double complex csinhl(long double complex z);$ + +Return~ +return complex hyperbolic sine of z + +Description~ +These functions compute the complex hyperbolic sine of z. +The mathematical definition of the complex hyperbolic sine is: + sinh(z) = 1/2 * (exp(z) - exp(-z)) / 2 + + + +ctanh() Functions *crv-ctanh* *crv-ctanhf* *crv-ctanhl* +----------------- +Synopsis~ + $#include <complex.h>$ + $double complex ctanh(double complex z);$ + $float complex ctanhf(float complex z);$ + $long double complex ctanhl(long double complex z);$ + +Return~ +return complex hyperbolic tangent of z + +Description~ +These functions compute the complex hyperbolic tangent of z. +The mathematical definition of the complex hyperbolic tangent is: + tanh(z) = sinh(z) / cosh(z) + + + +------------------------------------------------------------------------------ +II.3.5 Exponential & Logarithmic *crv-libCHExpLog* + + +cexp() Functions *crv-cexp* *crv-cexpf* *crv-cexpl* +---------------- +Synopsis~ + $#include <complex.h>$ + $double complex cexp(double complex z);$ + $float complex cexpf(float complex z);$ + $long double complex cexpl(long double complex z);$ + +Return~ +return complex base e exponential of z + +Description~ +These functions compute e (the base of natural logarithms) raised to the power +of z. Mathematically, this corresponds to the value + + exp(z) = exp(creal(z)) * (cos(cimag(z)) + I * sin(cimag(z))) + + + +clog() Functions *crv-clog* *crv-clogf* *crv-clogl* +---------------- +Synopsis~ + $#include <complex.h>$ + $double complex clog(double complex z);$ + $float complex clogf(float complex z);$ + $long double complex clogl(long double complex z);$ + +Return~ +return complex natural logarithm of z +Range: real > 0 + +Description~ +These functions compute the complex natural logarithm of z (base e). +Domain: imaginary is [-iPI, +iPI], real is unbounded + +The mathematical definition is: + log(z) = log(cabs(z)) + I * carg(z) + + + +------------------------------------------------------------------------------ +II.3.6 Power & Absolute *crv-libCHPower* + + +cabs() Functions *crv-cabs* *crv-cabsf* *crv-cabsl* +---------------- +Synopsis~ + $#include <complex.h>$ + $double cabs(double complex z);$ + $float cabsf(float complex z);$ + $long double cabsl(long double complex z);$ + +Return~ +return absolute value of z + +Description~ +These functions compute the absolute value of the complex number z. + + ------------------------ + absolute value = \|creal(z)^2 + cimag(z)^2 + + + +cpow() Functions *crv-cpow* *crv-cpowf* *crv-cpowl* +---------------- +Synopsis~ + $#include <complex.h>$ + $double complex cpow(double complex base, double complex power);$ + $float complex cpowf(float complex base, double complex power);$ + $long double complex cpowl(long double complex base,$ + $ long doubl complex power);$ + +Return~ +return complex power of z + +Description~ +These functions compute the complex power function x^y +($base$raised to the power$power$). + +This is equivalent to: + exp(y * log(x)) + + + +csqrt() Functions *crv-csqrt* *crv-csqrtf* *crv-csqrtl* +----------------- +Synopsis~ + $#include <complex.h>$ + $double complex csqrt(double complex z);$ + $float complex csqrtf(float complex z);$ + $long double complex csqrtl(long double complex z);$ + +Return~ +return complex square root of z +Range: real >= 0 + +Description~ +These functions compute the complex square root of z. +Domain: imaginary unbounded, real >= 0 + + + +------------------------------------------------------------------------------ +II.3.7 Manipulating *crv-libCHMani* + + +carg() Functions *crv-carg* *crv-cargf* *crv-cargl* +---------------- +Synopsis~ + $#include <complex.h>$ + $double carg(double complex z);$ + $float cargf(float complex z);$ + $long double cargl(long double complex z);$ + +Return~ +return argument of z +Range: [-PI, +PI] + +Description~ +These functions compute the argument of the complex number z. +The argument of a complex number is the angle in the complex plane between the +positive real axis and a line passing through zero and the number. +Domain: branch cut along the positive real axis + + + +cimag() Functions *crv-cimag* *crv-cimagf* *crv-cimagl* +----------------- +Synopsis~ + $#include <complex.h>$ + $double cimag(double complex z);$ + $float cimagf(float complex z);$ + $long double cimagl(long double complex z);$ + +Return~ +return imaginary part of z + +Description~ +These functions compute the imaginary part of the complex number z. + + + +conj() Functions *crv-conj* *crv-conjf* *crv-conjl* +---------------- +Synopsis~ + $#include <complex.h>$ + $double complex conj(double complex z);$ + $float complex conjf(float complex z);$ + $long double complex conjl(long double complex z);$ + +Return~ +return complex conjugate value of z + +Description~ +These functions compute the complex conjugate of the complex number z. +The conjugate of a complex number has the same real part and a negated +imaginary part. In other words, conj(a + bi) = a + -bi. + + + +cproj() Functions *crv-cproj* *crv-cprojf* *crv-cprojl* +----------------- +Synopsis~ + $#include <complex.h>$ + $double complex cproj(double complex z);$ + $float complex cprojf(float complex z);$ + $long double complex cprojl(long double complex z);$ + +Return~ +return value of projection onto the Riemann sphere + +Description~ +These functions compute the projection of the complex value z onto the Riemann +sphere. Values with a infinite imaginary part are projected to positive +infinity on the real axis, even if the real part is NaN. If the real part is +infinite, the result is equivalent to + INFINITY + I * copysign (0.0, cimag(z)) + + + +creal() Functions *crv-creal* *crv-crealf* *crv-creall* +----------------- +Synopsis~ + $#include <complex.h>$ + $double creal(double complex z);$ + $float crealf(float complex z);$ + $long double creall(long double complex z);$ + +Return~ +return real part of z + +Description~ +These functions compute the real part of the complex number z. + + + + +============================================================================== +II.4 <ctype.h> Character *crv-libCtypeH* + + +This header declares functions useful for case mapping and classifying +characters. + +Quicklink: + $isalnum()$ Func |crv-isalnum| + $isalpha()$ Func |crv-isalpha| + $isblank()$ Func |crv-isblank| + $iscntrl()$ Func |crv-iscntrl| + $isdigit()$ Func |crv-isdigit| + $isgraph()$ Func |crv-isgraph| + $islower()$ Func |crv-islower| + $isprint()$ Func |crv-isprint| + $ispunct()$ Func |crv-ispunct| + $isspace()$ Func |crv-isspace| + $isupper()$ Func |crv-isupper| + $isxdigit()$ Func |crv-isxdigit| + $tolower()$ Func |crv-tolower| + $toupper()$ Func |crv-toupper| + + + +------------------------------------------------------------------------------ +II.4.1 Character Handling *crv-libCharHandling* + +Each of the functions in this section tests for membership in a particular +class of characters; each has a name starting with is. Each of them takes +one argument, which is a character to test, and returns an int which is +treated as a boolean value. The character argument is passed as an int, +and it may be the constant value EOF instead of a real character. + +The attributes of any given character can vary between locales. + + +$int isalnum(int c);$ *crv-isalnum* + Returns true if c is an alphanumeric character (a letter or number); in + other words, if either$isalpha$or$isdigit$is true of a character, then + $isalnum$ is also true. + + +$int isalpha(int c);$ *crv-isalpha* + Returns true if c is an alphabetic character (a letter). If$islower$or + $isupper$is true of a character, then$isalpha$is also true. + It returns also true, if c is one of a local-specific set of characters for + which none of$iscntrl$,$isdigt$,$ispunct$ or$isspcace$is true. + + In some locales, there may be additional characters for which isalpha + is true - letters which are neither upper case nor lower case. But in + the standard C locale, there are no such additional characters. + + +$int isblank(int c);$ *crv-isblank* + Returns true if c is a blank character; that is, a space or a tab. + + +$int iscntrl(int c);$ *crv-iscntrl* + Returns true if c is a control character (that is, a character that is + not a printing character). + + +$int isdigit(int c);$ *crv-isdigit* + Returns true if c is a decimal digit (0 through 9). + + +$int isgraph(int c);$ *crv-isgraph* + Returns true if c is a graphic character; that is any printing character + except a space character. + + +$int islower(int c);$ *crv-islower* + Returns true if c is a lower-case letter or is one of a local-specific set + of characters for which none of$iscntrl$,$isdigt$,$ispunct$ or$isspcace$is + true. + + +$int isprint(int c);$ *crv-isprint* + Returns true if c is a printing character. Printing characters include + all the graphic characters, plus the space (' ') character. + + +$int ispunct(int c);$ *crv-ispunct* + Returns true if c is a punctuation character. This means any printing + character for that is neither$isalnum$nor$isspace$is true (no + alphanumeric and no space character). + + +$int isspace(int c);$ *crv-isspace* + Returns true if c is a whitespace character. In the standard "C" locale, + $isspace$returns true for only the standard whitespace characters: + ' ' space + '\f' formfeed + '\n' newline + '\r' carriage return + '\t' horizontal tab + '\v' vertical tab + + +$int isupper(int c);$ *crv-isupper* + Returns true if c is an upper-case letter or is one of a local-specific set + of characters for which none of$iscntrl$,$isdigt$,$ispunct$ or$isspcace$is + true. + + +$int isxdigit(int c);$ *crv-isxdigit* + Returns true if c is a hexadecimal digit. Hexadecimal digits include the + normal decimal digits 0 through 9 and the letters A through F and + a through f. + + + + +------------------------------------------------------------------------------ +II.4.2 Character Mapping *crv-libCharMapping* + +This section explains the functions for performing case mappings on +characters. +These functions take one argument of type int, which is the character to +convert, and return the converted character as an int. If the conversion is +not applicable to the argument given, the argument is returned unchanged. + + +$int tolower(int c);$ *crv-tolower* + If c is an upper-case letter,$tolower$returns the corresponding lower-case + letter. If c is not an upper-case letter, c is returned unchanged. + +$int toupper(int c);$ *crv-toupper* + If c is a lower-case letter,$toupper$returns the corresponding upper-case + letter. If c is not an lower-case letter, c is returned unchanged. + + + + +============================================================================== +II.5 <errno.h> Error Codes *crv-libErrnoH* + +This header file defines macros used for reporting of error conditions. +All macros expand to integer constant expressions of type$int$with distinct +positive values. + +Additional macro definitions may be specified by the implementation. They +begin with E followed by digits or begin with E followed by uppercase letters. + + +EDOM Macro *crv-EDOM* +---------- +Domain error; used by mathematical functions when an argument value does not +fall into the domain over which the function is defined. + + +EILSEQ Macro *crv-EILSEQ* +------------ +While decoding a multibyte character the function came along an invalid or an +incomplete sequence of bytes or the given wide character is invalid. + + +ERANGE Macro *crv-ERANGE* +------------ +Range error; used by mathematical functions when the result value is not +representable because of overflow or underflow. + + +errno Macro/Variable *crv-errno* +-------------------- +$errno$is either a macro or an external variable of type int (implementation- +defined). + +The$errno$variable is used for holding implementation-defined error codes +reported by library routines. See above for error code macros specified by the +standard C language. +The value of$errno$is set to 0 at program startup, but is never set to 0 +by any library function. Therefore,$errno$should be set to 0 before calling a +library function and then inspected afterward. + + + + +------------------------------------------------------------------------------ +II.6 <fenv.h> FPU Status *crv-libFenvH* + +This header declares types, macros and functions to provide access to the +floating-point environment (floating-point status word and control modes). + +Quicklink: + $FE_ALL_EXCEPT$ Macro |crv-FE_ALL_EXCEPT| + $FE_DIVBYZERO$ Macro |crv-FE_DIVBYZERO| + $FE_DOWNWARD$ Macro |crv-FE_DOWNWARD| + $FE_INEXACT$ Macro |crv-FE_INEXACT| + $FE_INVALID$ Macro |crv-FE_INVALID| + $FE_OVERFLOW$ Macro |crv-FE_OVERFLOW| + $FE_TONEAREST$ Macro |crv-FE_TONEAREST| + $FE_TOWARDZERO$ Macro |crv-FE_TOWARDZERO| + $FE_UNDERFLOW$ Macro |crv-FE_UNDERFLOW| + $FE_UPWARD$ Macro |crv-FE_UPWARD| + $FENV_ACCESS$ Pragma |crv-FENV_ACCESS| + $feclearexcept()$ Func |crv-feclearexcept| + $fegetenv()$ Func |crv-fegetenv| + $fegetexceptflag()$ Func |crv-fegetexceptflag| + $fegetround()$ Func |crv-fegetround| + $feholdexcept()$ Func |crv-feholdexcept| + $feraiseexcept()$ Func |crv-feraiseexcept| + $fesetenv()$ Func |crv-fesetenv| + $fesetexceptflag()$ Func |crv-fesetexceptflag| + $fesetround()$ Func |crv-fesetround| + $fetestexcept()$ Func |crv-fetestexcept| + $feupdateenv()$ Func |crv-feupdateenv| + + + +------------------------------------------------------------------------------ +II.6.1 Pragmas *crv-libFHPrag* + +FENV_ACCESS Pragma *crv-FENV_ACCESS* +------------------ +Synopsis~ + $#include <fenv.h>$ + $#pragma STDC FENV_ACCESS on/off-switch$ + + $on/off-switch$is$ON$,$OFF$or$DEFAULT$ + +Description~ +This pragma provides a means to inform the compiler when a program might +access the floating-point environment (FPU or software emulation of FP) to +test status flags or run under non-default control modes. An "off"-state +signals that a program does not test status flags and does not run under +non-default control modes. Knowing this the compiler can do better +optimization that could subvert flag tests or mode changes. + +When inside a compound statement, the pragma takes effect from its occurrence +until end of compound statement or until the next$FENV_ACCESS$is encountered; +at the end of a compound statement the state of the pragma is restored to its +state just before entering that compound statement. +When outside a compound statement, the pragma takes effect from its occurrence +until end of source-file or until the next$FENV_ACCESS$is encountered. +The default state of this pragma is implementation-defined. + + + +------------------------------------------------------------------------------ +II.6.2 Exceptions *crv-libFHExceptions* + +The following functions allow to query and manipulate the floating-point +status word. They can be used to check for untrapped exceptions when it's +convenient, rather than worrying about them in the middle of a calculation. + +The macros below represent the various IEEE 754 exceptions. Not all FPUs +report all the different exceptions. Each constant is defined if and only if +the FPU compiling for supports that exception.$#ifdef$can be used to test for +FPU support. +Additional macro definitions may be specified by the implementation. They +begin with FE_ followed by uppercase letters. + + +FE_INEXACT Macro *crv-FE_INEXACT* +---------------- +The inexact exception. + + +FE_DIVBYZERO Macro *crv-FE_DIVBYZERO* +------------------ +The divide by zero exception. + + +FE_UNDERFLOW Macro *crv-FE_UNDERFLOW* +------------------ +The underflow exception. + + +FE_OVERFLOW Macro *crv-FE_OVERFLOW* +----------------- +The overflow exception. + + +FE_INVALID Macro *crv-FE_INVALID* +---------------- +The invalid exception. + + +FE_ALL_EXCEPT Macro *crv-FE_ALL_EXCEPT* +------------------- +This macro is the bitwise OR of all exception macros which are supported by +the FP implementation. + + +feclearexcept() Function *crv-feclearexcept* +------------------------ +Synopsis~ + $#include <fenv.h>$ + $int feclearexcept(int excepts);$ + +Return~ +zero in case the operation was successful, otherwise a non-zero value + +Description~ +This function clears all of the supported exception flags indicated by +$excepts$. + + +fegetexceptflag() Function *crv-fegetexceptflag* +-------------------------- +Synopsis~ + $#include <fenv.h>$ + $int fegetexceptflag(fexcept_t *flagp, int excepts);$ + +Return~ +zero in case the operation was successful, otherwise a non-zero value + +Description~ +This function attempts to store in the variable pointed to by$flagp$an +implementation-defined value representing the current setting of the +exception flags indicated by$excepts$. + + +feraiseexcept() Function *crv-feraiseexcept* +------------------------ +Synopsis~ + $#include <fenv.h>$ + $int feraiseexcept(int excepts);$ + +Return~ +zero in case the operation was successful, otherwise a non-zero value + +Description~ +This function attempts to raises the supported exceptions indicated by +$excepts$. If more than one exception bit in$excepts$is set the order in which +the exceptions are raised is undefined except that overflow ($FE_OVERFLOW$) or +underflow ($FE_UNDERFLOW$) are raised before inexact ($FE_INEXACT$). Whether +for overflow or underflow the inexact exception is also raised is also +implementation dependent. + + +fesetexceptflag() Function *crv-fesetexceptflag* +-------------------------- +Synopsis~ + $#include <fenv.h>$ + $int fesetexceptflag(fexcept_t *flagp, int excepts);$ + +Return~ +zero in case the operation was successful, otherwise a non-zero value + +Description~ +This function attempts to restore the flags for the exceptions indicated by +$excepts$to the values stored in the variable pointed to by $flagp$. + + +fetestexcept() Function *crv-fetestexcept* +----------------------- +Synopsis~ + $#include <fenv.h>$ + $int fetestexcept(int excepts);$ + +Return~ +flags which are set + +Description~ +Test whether the exception flags indicated by the parameter$except$are +currently set. If any of them are, a nonzero value is returned which specifies +which exceptions are set. Otherwise the result is zero. + + + +------------------------------------------------------------------------------ +II.6.3 Rounding *crv-libFHRounding* + +Floating-point calculations are carried out internally with extra precision, +and then rounded to fit into the destination type. This ensures that results +are as precise as the input data. IEEE 754 defines four possible rounding +modes: + +- Round to nearest + This is the default mode. It should be used unless there is a specific need + for one of the others. In this mode results are rounded to the nearest + representable value. If the result is midway between two representable + values, the even representable is chosen. Even here means the lowest-order + bit is zero. This rounding mode prevents statistical bias and guarantees + numeric stability: round-off errors in a lengthy calculation will remain + smaller than half of$FLT_EPSILON$. + +- Round toward plus Infinity + All results are rounded to the smallest representable value which is greater + than the result. + +- Round toward minus Infinity + All results are rounded to the largest representable value which is less + than the result. + +- Round toward zero + All results are rounded to the largest representable value whose magnitude + is less than that of the result. In other words, if the result is negative + it is rounded up; if it is positive, it is rounded down. + +For examples of effects see |crv-FLT_ROUNDS|. + +$<fenv.h>$defines constants which you can use to refer to the various rounding +modes. Each one will be defined if and only if the FPU supports the +corresponding rounding mode. + + +FE_TONEAREST Macro *crv-FE_TONEAREST* +------------------ +Round to nearest. + + +FE_UPWARD Macro *crv-FE_UPWARD* +--------------- +Round toward +∞. + + +FE_DOWNWARD Macro *crv-FE_DOWNWARD* +----------------- +Round toward -∞. + + +FE_TOWARDZERO Macro *crv-FE_TOWARDZERO* +------------------- +Round toward zero. + + +Underflow is an unusual case. Normally, IEEE 754 floating point numbers are +always normalized. Numbers smaller than 2^r (where r is the minimum exponent +cannot be represented as normalized numbers. Rounding all such numbers to zero +or 2^r would cause some algorithms to fail at 0. Therefore, they are left in +denormalized form. That produces loss of precision, since some bits of the +mantissa are stolen to indicate the decimal point. + +If a result is too small to be represented as a denormalized number, it is +rounded to zero. However, the sign of the result is preserved; if the +calculation was negative, the result is negative zero. Negative zero can also +result from some operations on infinity, such as 4/-∞. Negative zero +behaves identically to zero except when the copysign or signbit functions are +used to check the sign bit directly. + + +At any time one of the above four rounding modes is selected. The following +functions allow to get and set the rounding modes: + + +fegetround() Function *crv-fegetround* +--------------------- +Synopsis~ + $#include <fenv.h>$ + $int fegetround(void);$ + +Return~ +currently selected rounding mode + +Description~ +Returns the currently selected rounding mode, represented by one of the values +of the defined rounding mode macros. + + +fesetround() Function *crv-fesetround* +--------------------- +Synopsis~ + $#include <fenv.h>$ + $int fesetround(int round);$ + +Return~ +zero if it changed the rounding mode, a nonzero value if the mode is not +supported + +Description~ +Changes the currently selected rounding mode to$round$. If$round$does not +correspond to one of the supported rounding modes nothing is changed. + +You should avoid changing the rounding mode if possible. It can be an +expensive operation; also, some hardware requires you to compile your +program differently for it to work. The resulting code may run slower. See +your compiler documentation for details. + + + + +------------------------------------------------------------------------------ +II.6.4 Environment *crv-libFHEnv* + +The functions in this section manage the floating-point environment. + + *crv-fentv_t* +The functions to save and restore the floating-point environment all use a +variable of type$fenv_t$to store information. This type is defined in +$<fenv.h>$. Its size and contents are implementation-defined. This variable +should not be manipulated directly. + + +fegetenv() Function *crv-fegetenv* +------------------- +Synopsis~ + $#include <fenv.h>$ + $int fegetenv(fenv_t *envp);$ + +Return~ +zero in case the operation was successful, otherwise a non-zero value + +Description~ +Store the floating-point environment in the variable pointed to by$envp$. + + +feholdexcept() Function *crv-feholdexcept* +----------------------- +Synopsis~ + $#include <fenv.h>$ + $int feholdexcept(fenv_t *envp);$ + +Return~ +zero in case the operation was successful, otherwise a non-zero value + +Description~ +Store the current floating-point environment in the object pointed to by +$envp$. Then clear all exception flags, and set the FPU to trap no exceptions. +Not all FPUs support trapping no exceptions; if$feholdexcept$cannot set this +mode, it returns nonzero value. + + +fesetenv() Function *crv-fesetenv* +------------------- +Synopsis~ + $#include <fenv.h>$ + $int fesetenv(const fenv_t *envp);$ + +Return~ +zero in case the operation was successful, otherwise a non-zero value + +Description~ +Set the floating-point environment to that described by$envp$. + + +feupdateenv() Function *crv-feupdateenv* +---------------------- +Synopsis~ + $#include <fenv.h>$ + $int feupdateenv(const fenv_t *envp);$ + +Return~ +zero in case the operation was successful, otherwise a non-zero value + +Description~ +Like$fesetenv()$, this function sets the floating-point environment to that +described by$envp$. However, if any exceptions were flagged in the status word +before$feupdateenv()$was called, they remain flagged after the call. In other +words, after$feupdateenv()$is called, the status word is the bitwise OR of the +previous status word and the one saved in$envp$. + + + + +============================================================================== +II.7 <float.h> Floating Point *crv-libFloatH* + +This header file defines several macros that expand to various +implementation-specific limits and parameters describing floating-point +properties. +NOTE: The values are platform- and implementation-specific.The ISO C standard +specifies minimum and maximum values for most of these parameters. + +Macro names starting with FLT_ refer to the float type, while names beginning +with DBL_ refer to the double type and names beginning with LDBL_ refer to the +long double type. + +Quicklink: + $FLT_DIG $ Macro |crv-FLT_DIG| + $FLT_EPSILON $ Macro |crv-FLT_EPSILON| + $FLT_MANT_DIG $ Macro |crv-FLT_MANT_DIG| + $FLT_MAX $ Macro |crv-FLT_MAX| + $FLT_MAX_10_EXP $ Macro |crv-FLT_MAX_10_EXP| + $FLT_MAX_EXP $ Macro |crv-FLT_MAX_EXP| + $FLT_MIN $ Macro |crv-FLT_MIN| + $FLT_MIN_10_EXP $Macro |crv-FLT_MIN_10_EXP| + $FLT_MIN_EXP $ Macro |crv-FLT_MIN_EXP| + $FLT_RADIX $ Macro |crv-FLT_RADIX| + $FLT_ROUNDS $ Macro |crv-FLT_ROUNDS| + $DBL_DIG $ Macro |crv-DBL_DIG| + $DBL_EPSILON $ Macro |crv-DBL_EPSILON| + $DBL_MANT_DIG $ Macro |crv-DBL_MANT_DIG| + $DBL_MAX $ Macro |crv-DBL_MAX| + $DBL_MAX_10_EXP $ Macro |crv-DBL_MAX_10_EXP| + $DBL_MAX_EXP $ Macro |crv-DBL_MAX_EXP| + $DBL_MIN $ Macro |crv-DBL_MIN| + $DBL_MIN_10_EXP $Macro |crv-DBL_MIN_10_EXP| + $DBL_MIN_EXP $ Macro |crv-DBL_MIN_EXP| + $LDBL_DIG $ Macro |crv-LDBL_DIG| + $LDBL_EPSILON $ Macro |crv-LDBL_EPSILON| + $LDBL_MANT_DIG $ Macro |crv-LDBL_MANT_DIG| + $LDBL_MAX $ Macro |crv-LDBL_MAX| + $LDBL_MAX_10_EXP$ Macro |crv-LDBL_MAX_10_EXP| + $LDBL_MAX_EXP $ Macro |crv-LDBL_MAX_EXP| + $LDBL_MIN $ Macro |crv-LDBL_MIN| + $LDBL_MIN_10_EXP $Macro |crv-LDBL_MIN_10_EXP| + $LDBL_MIN_EXP $ Macro |crv-LDBL_MIN_EXP| + + + +FLT_ROUNDS Macro *crv-FLT_ROUNDS* +---------------- +This value characterizes the rounding mode for floating point addition. The +following values indicate standard rounding modes: + + Value | Mode + --------+---------------------------------------------------------------- + -1 | the mode is indeterminable + 0 | rounding is towards zero, see |crv-libFHRounding| + 1 | rounding is to the nearest number, see |crv-libFHRounding| + 2 | rounding is towards positive infinity, see |crv-libFHRounding| + 3 | rounding is towards negative infinity, see |crv-libFHRounding| + +Any other value represents a machine-dependent nonstandard rounding mode. + +On most machines, the value is 1, in accordance with the IEEE standard for +floating point. + +Here is a table showing how certain values round for each possible value +of$FLT_ROUNDS$, if the other aspects of the representation match the IEEE +single-precision standard: + + Value | 0 | 1 | 2 | 3 + ------------+------+-------------+-------------+------------- + 1.00000003 | 1.0 | 1.0 | 1.00000012 | 1.0 + 1.00000007 | 1.0 | 1.00000012 | 1.00000012 | 1.0 + -1.00000003 | -1.0 | -1.0 | -1.0 | -1.00000012 + -1.00000007 | -1.0 | -1.00000012 | -1.0 | -1.00000012 + + + +FLT_RADIX Macro *crv-FLT_RADIX* +--------------- +This is the value of the base, or radix, of the exponent representation. In +the very most times the value is 2 (except IBM 360 and derivatives). + + +FLT_MANT_DIG Macro *crv-FLT_MANT_DIG* +DBL_MANT_DIG Macro *crv-DBL_MANT_DIG* +LDBL_MANT_DIG Macro *crv-LDBL_MANT_DIG* +------------------ +This is the number of base-$FLT_RADIX$digits in the floating point mantissa. + + +FLT_DIG Macro *crv-FLT_DIG* +DBL_DIG Macro *crv-DBL_DIG* +LDBL_DIG Macro *crv-LDBL_DIG* +-------------- +This is the number of decimal digits of precision. +To satisfy standard C, the values supposed to be at least: + FLT_DIG >= 6 + DBL_DIG >= 10 + LDBL_DIG >= 10 + +Technically, if p and b are the precision and base (respectively) for the +representation, then the decimal precision q is the maximum number of decimal +digits such that any floating point number with q base 10 digits can be +rounded to a floating point number with p base b digits and back again, +without change to the q decimal digits. + + +FLT_MIN_EXP Macro *crv-FLT_MIN_EXP* +DBL_MIN_EXP Macro *crv-DBL_MIN_EXP* +LDBL_MIN_EXP Macro *crv-LDBL_MIN_EXP* +------------------ +This is the minimum negative integer value for an exponent in base$FLT_RADIX$. + + +FLT_MIN_10_EXP Macro *crv-FLT_MIN_10_EXP* +DBL_MIN_10_EXP Macro *crv-DBL_MIN_10_EXP* +LDBL_MIN_10_EXP Macro *crv-LDBL_MIN_10_EXP* +--------------------- +This is the minimum negative integer value for an exponent in base 10. +To satisfy standard C, the values supposed to be at least: + FLT_MIN_10_EXP <= -37 + DBL_MIN_10_EXP <= -37 + LDBL_MIN_10_EXP <= -37 + + +FLT_MAX_EXP Macro *crv-FLT_MAX_EXP* +DBL_MAX_EXP Macro *crv-DBL_MAX_EXP* +LDBL_MAX_EXP Macro *crv-LDBL_MAX_EXP* +------------------ +This is the maximum integer value for an exponent in base$FLT_RADIX$. + + +FLT_MAX_10_EXP Macro *crv-FLT_MAX_10_EXP* +DBL_MAX_10_EXP Macro *crv-DBL_MAX_10_EXP* +LDBL_MAX_10_EXP Macro *crv-LDBL_MAX_10_EXP* +--------------------- +This is the maximum integer value for an exponent in base 10. +To satisfy standard C, the values supposed to be at least: + FLT_MAX_10_EXP >= -37 + DBL_MAX_10_EXP >= -37 + LDBL_MAX_10_EXP >= -37 + + + +FLT_MAX Macro *crv-FLT_MAX* +DBL_MAX Macro *crv-DBL_MAX* +LDBL_MAX Macro *crv-LDBL_MAX* +-------------- +The value is the maximum finite number representable. +To satisfy standard C, the values supposed to be at least: + FLT_MAX >= 1E+37 + DBL_MAX >= 1E+37 + LDBL_MAX >= 1E+37 + +The smallest representable number is -FLT_MAX, -DBL_MAX, -LDBL_MAX. + + +FLT_MIN Macro *crv-FLT_MIN* +DBL_MIN Macro *crv-DBL_MIN* +LDBL_MIN Macro *crv-LDBL_MIN* +-------------- +The value is the minimum number representable. +To satisfy standard C, the values supposed to be at least: + FLT_MIN <= 1E-37 + DBL_MIN <= 1E-37 + LDBL_MIN <= 1E-37 + + +FLT_EPSILON Macro *crv-FLT_EPSILON* +DBL_EPSILON Macro *crv-DBL_EPSILON* +LDBL_EPSILON Macro *crv-LDBL_EPSILON* +------------------ +This is the maximum positive floating point number such that +1.0 +$FLT_EPSILON$!= 1.0 is true (least significant digit representable). + +To satisfy standard C, the values supposed to be at least: + FLT_EPSILON >= 1E-5 + DBL_EPSILON >= 1E-9 + LDBL_EPSILON >= 1E-9 + + + +============================================================================== +II.8 <inttypes.h> Absolute Value *crv-libInttypesH* + +This header extends the$<stdint.h>$header (->|crv-libStdintH|). It provides +macros for format conversion of integer types and provides functions for +manipulating greatest-width integer types. + +Quicklink: + $imaxdiv_t$ Type |crv-imaxdiv_t| + $imaxabs$ Func |crv-imaxabs| + $imaxdiv$ Func |crv-imaxdiv| + + $PRIdN$ Macro |crv-PRIdN| + $PRIdLEASTN$ Macro |crv-PRIdLEASTN| + $PRIdFASTN$ Macro |crv-PRIdFASTN| + $PRIdMAX$ Macro |crv-PRIdMAX| + $PRIdPTR$ Macro |crv-PRIdPTR| + + $PRIiN$ Macro |crv-PRIiN| + $PRIiLEASTN$ Macro |crv-PRIiLEASTN| + $PRIiFASTN$ Macro |crv-PRIiFASTN| + $PRIiMAX$ Macro |crv-PRIiMAX| + $PRIiPTR$ Macro |crv-PRIiPTR| + + $PRIoN$ Macro |crv-PRIoN| + $PRIoLEASTN$ Macro |crv-PRIoLEASTN| + $PRIoFASTN$ Macro |crv-PRIoFASTN| + $PRIoMAX$ Macro |crv-PRIoMAX| + $PRIoPTR$ Macro |crv-PRIoPTR| + + $PRIuN$ Macro |crv-PRIuN| + $PRIuLEASTN$ Macro |crv-PRIuLEASTN| + $PRIuFASTN$ Macro |crv-PRIuFASTN| + $PRIuMAX$ Macro |crv-PRIuMAX| + $PRIuPTR$ Macro |crv-PRIuPTR| + + $PRIxN$ Macro |crv-PRIxN| + $PRIxLEASTN$ Macro |crv-PRIxLEASTN| + $PRIxFASTN$ Macro |crv-PRIxFASTN| + $PRIxMAX$ Macro |crv-PRIxMAX| + $PRIxPTR$ Macro |crv-PRIxPTR| + + $PRIXN$ Macro |crv-PRIXN| + $PRIXLEASTN$ Macro |crv-PRIXLEASTN| + $PRIXFASTN$ Macro |crv-PRIXFASTN| + $PRIXMAX$ Macro |crv-PRIXMAX| + $PRIXPTR$ Macro |crv-PRIXPTR| + + $SCNdN$ Macro |crv-SCNdN| + $SCNdLEASTN$ Macro |crv-SCNdLEASTN| + $SCNdFASTN$ Macro |crv-SCNdFASTN| + $SCNdMAX$ Macro |crv-SCNdMAX| + $SCNdPTR$ Macro |crv-SCNdPTR| + + $SCNiN$ Macro |crv-SCNiN| + $SCNiLEASTN$ Macro |crv-SCNiLEASTN| + $SCNiFASTN$ Macro |crv-SCNiFASTN| + $SCNiMAX$ Macro |crv-SCNiMAX| + $SCNiPTR$ Macro |crv-SCNiPTR| + + $SCNoN$ Macro |crv-SCNoN| + $SCNoLEASTN$ Macro |crv-SCNoLEASTN| + $SCNoFASTN$ Macro |crv-SCNoFASTN| + $SCNoMAX$ Macro |crv-SCNoMAX| + $SCNoPTR$ Macro |crv-SCNoPTR| + + $SCNuN$ Macro |crv-SCNuN| + $SCNuLEASTN$ Macro |crv-SCNuLEASTN| + $SCNuFASTN$ Macro |crv-SCNuFASTN| + $SCNuMAX$ Macro |crv-SCNuMAX| + $SCNuPTR$ Macro |crv-SCNuPTR| + + $SCNxN$ Macro |crv-SCNxN| + $SCNxLEASTN$ Macro |crv-SCNxLEASTN| + $SCNxFASTN$ Macro |crv-SCNxFASTN| + $SCNxMAX$ Macro |crv-SCNxMAX| + $SCNxPTR$ Macro |crv-SCNxPTR| + + $strtoimax$ Func |crv-strtoimax| + $strtoumax$ Func |crv-strtoumax| + $wcstoimax$ Func |crv-wcstoimax| + $wcstoumax$ Func |crv-wcstoumax| + + +Macros *crv-__STDC_FORMAT_MACROS* +------ +The following macros expand to a string (in most cases a single character) +containing a conversion specifier suitable for use within format arguments +of formated input/output functions, like$printf()$or$scanf()$. +They are only defined when$__STDC_FORMAT_MACROS$is defined before including +$<inttypes.h>$. +For each type declared in$<stdint.h>$, corresponding macros for conversion +specifiers for use with the formatted input/output functions are defined. + +The macro names have a prefix PRI for the printf family or SCN for the +scanf family functions followed by the conversion specifier, followed by name +that is similar to the type name this macro is for, followed by a number N. +The number N represents the width of the type as specified in$<stdint.h>.$ + +Example: The macro$PRIxFAST32$can be used in a format string to print an +integer value of type$int_fast32_t$in hexedecimal format ('x'). + +Usage see example below. + + +Format Specifiers for ..printf +------------------------------ + +Signed Integers: +$PRIdN$ width N, decimal notation *crv-PRIdN* +$PRIdLEASTN$ minimum width N, decimal notation *crv-PRIdLEASTN* +$PRIdFASTN$ width N, fast to operate with, decimal not. *crv-PRIdFASTN* +$PRIdMAX$ type$intmax_t$, decimal notation *crv-PRIdMAX* +$PRIdPTR$ type$intptr_t$, decimal notation *crv-PRIdPTR* + +$PRIiN$ width N, decimal notation *crv-PRIiN* +$PRIiLEASTN$ minimum width N, decimal notation *crv-PRIiLEASTN* +$PRIiFASTN$ width N, fast to operate with, decimal not. *crv-PRIiFASTN* +$PRIiMAX$ type$intmax_t$, decimal notation *crv-PRIiMAX* +$PRIiPTR$ type$intptr_t$, decimal notation *crv-PRIiPTR* + +Unsigned Integers: +$PRIoN$ width N, octal notation *crv-PRIoN* +$PRIoLEASTN$ minimum width N, octal notation *crv-PRIoLEASTN* +$PRIoFASTN$ width N, fast to operate with, octal not. *crv-PRIoFASTN* +$PRIoMAX$ type$intmax_t$, octal notation *crv-PRIoMAX* +$PRIoPTR$ type$intptr_t$, octal notation *crv-PRIoPTR* + +$PRIuN$ width N, decimal notation *crv-PRIuN* +$PRIuLEASTN$ minimum width N, decimal notation *crv-PRIuLEASTN* +$PRIuFASTN$ width N, fast to operate with, decimal not. *crv-PRIuFASTN* +$PRIuMAX$ type$intmax_t$, decimal notation *crv-PRIuMAX* +$PRIuPTR$ type$intptr_t$, decimal notation *crv-PRIuPTR* + +$PRIxN$ width N, lowercase hex. notation *crv-PRIxN* +$PRIxLEASTN$ minimum width N, lowercase hex. notation *crv-PRIxLEASTN* +$PRIxFASTN$ width N, fast operation, lowercase hex. not *crv-PRIxFASTN* +$PRIxMAX$ type$intmax_t$, lowercase hex. notation *crv-PRIxMAX* +$PRIxPTR$ type$intptr_t$, lowercase hex. notation *crv-PRIxPTR* + +$PRIXN$ width N, uppercase hex. notation *crv-PRIXN* +$PRIXLEASTN$ minimum width N, uppercase hex. notation *crv-PRIXLEASTN* +$PRIXFASTN$ width N, fast operation, uppercase hex. not. *crv-PRIXFASTN* +$PRIXMAX$ type$intmax_t$, uppercase hex. notation *crv-PRIXMAX* +$PRIXPTR$ type$intptr_t$, uppercase hex. notation *crv-PRIXPTR* + + +Format Specifiers for ..scanf +----------------------------- + +Signed Integers: +$SCNdN$ width N, decimal notation *crv-SCNdN* +$SCNdLEASTN$ minimum width N, decimal notation *crv-SCNdLEASTN* +$SCNdFASTN$ width N, fast to operate with, decimal not. *crv-SCNdFASTN* +$SCNdMAX$ type$intmax_t$, decimal notation *crv-SCNdMAX* +$SCNdPTR$ type$intptr_t$, decimal notation *crv-SCNdPTR* + +$SCNiN$ width N, decimal notation *crv-SCNiN* +$SCNiLEASTN$ minimum width N, decimal notation *crv-SCNiLEASTN* +$SCNiFASTN$ width N, fast to operate with, decimal not. *crv-SCNiFASTN* +$SCNiMAX$ type$intmax_t$, decimal notation *crv-SCNiMAX* +$SCNiPTR$ type$intptr_t$, decimal notation *crv-SCNiPTR* + +Unsigned Integers: +$SCNoN$ width N, octal notation *crv-SCNoN* +$SCNoLEASTN$ minimum width N, octal notation *crv-SCNoLEASTN* +$SCNoFASTN$ width N, fast to operate with, octal not. *crv-SCNoFASTN* +$SCNoMAX$ type$intmax_t$, octal notation *crv-SCNoMAX* +$SCNoPTR$ type$intptr_t$, octal notation *crv-SCNoPTR* + +$SCNuN$ width N, decimal notation *crv-SCNuN* +$SCNuLEASTN$ minimum width N, decimal notation *crv-SCNuLEASTN* +$SCNuFASTN$ width N, fast to operate with, decimal not. *crv-SCNuFASTN* +$SCNuMAX$ type$intmax_t$, decimal notation *crv-SCNuMAX* +$SCNuPTR$ type$intptr_t$, decimal notation *crv-SCNuPTR* + +$SCNxN$ width N, hex. notation *crv-SCNxN* +$SCNxLEASTN$ minimum width N, hex. notation *crv-SCNxLEASTN* +$SCNxFASTN$ width N, fast operation, hex. not *crv-SCNxFASTN* +$SCNxMAX$ type$intmax_t$, hex. notation *crv-SCNxMAX* +$SCNxPTR$ type$intptr_t$, hex. notation *crv-SCNxPTR* + + +Example: > + #define __STDC_FORMAT_MACROS + + #include <inttypes.h> + #include <stdio.h> + + int main(void) + { + int16_t n = -123; + + printf("Value is %4" PRIu16 "\n", n); + } + + + +imaxdiv_t Type *crv-imaxdiv_t* +-------------- +This is a structure type used to hold the result returned by the$imaxdiv()$ +function. It holds both, the quotient and the remainder from the division. + + + +imaxabs() Function *crv-imaxabs* +------------------- +Synopsis~ + $#include <inttypes.h>$ + $intmax_t imaxabs(intmax_t j);$ + +Return~ +absolute value of$j$ + +Description~ +This function computes the absolute value of an integer$j$. + + + +imaxdiv() Function *crv-imaxdiv* +------------------- +Synopsis~ + $#include <inttypes.h>$ + $intdiv_t imaxdiv(intmax_t numerator, intmax_t denominator );$ + +Return~ +returns result of division and modulo operation, both stored in$intdiv_t$ +structur + +Description~ +This functions computes$numerator / denominator$and$numerator % denominator$in +a single operation. + + + +strtoimax() Function *crv-strtoimax* +-------------------- +Synopsis~ + $#include <inttypes.h>$ + $intmax_t strtoimax(const char *restrict string, char **restrict tailptr,$ + $int base);$ + +Return~ +converted value + +Description~ +This function ("string-to-imax") converts the initial part of$string$to a +signed integer, which is returned as a value of type$intmax_t$. +See$strol()$for description of parameters (|crv-libstrtol|). + + + +strtoumax() Function *crv-strtoumax* +-------------------- +Synopsis~ + $#include <inttypes.h>$ + $uintmax_t strtoumax(const char *restrict string, char **restrict tailptr,$ + $int base);$ + +Return~ +converted value + +Description~ +This function ("string-to-umax") converts the initial part of$string$to a +signed integer, which is returned as a value of type$uintmax_t$. +See$stroul()$for description of parameters (|crv-libstrtoul|). + + + +wcstoimax() Function *crv-wcstoimax* +-------------------- +Synopsis~ + $#include <stddef.h> // for wchar_t$ + $#include <inttypes.h>$ + $wchar_t wcstoimax(const wchar_t *restrict string,$ + $wchar_t **restrict tailptr, int base);$ + +Return~ +converted value + +Description~ +This function is equivalent to the$strtoimax()$function in nearly all aspects +but handles wide character strings (see |crv-libstrtoimax| for further +information). + + + +wcstoumax() Function *crv-wcstoumax* +-------------------- +Synopsis~ + $#include <stddef.h> // for wchar_t$ + $#include <inttypes.h>$ + $wchar_t wcstoimax(const wchar_t *restrict string,$ + $wchar_t **restrict tailptr, int base);$ + +Return~ +converted value + +Description~ +This function is equivalent to the$strtoumax()$function in nearly all aspects +but handles wide character strings (see |crv-libstrtoumax| for further +information). + + + +============================================================================== +II.9 <iso646.h> Alternatives *crv-libIso646H* + +This header defines some macros. They can be used for alternative spellings. + + Macro | Expands to + ----------+------------ + $and$ | $&&$ + $and_eq$ | $&=$ + $bitand$ | $&$ + $bitor$ | $|$ + $compl$ | $~$ + $not$ | $!$ + $not_eq$ | $!=$ + $or$ | $||$ + $or_eq$ | $|=$ + $xor$ | $^$ + $xor_eq$ | $^=$ + + + +============================================================================== +II.10 <limits.h> Limits of Integer Types *crv-libLimitsH* + +This header file defines several macros that expand to various limits and +parameters of the integer types. +NOTE: The values are platform- and implementation-specific.The ISO C standard +specifies minimum and maximum values for most of these parameters. + +The macros of this header can be grouped in: + - range of integer type + - width of type + - selection of conversion and its properties + + +Quicklink: + $CHAR_BIT$ Macro |crv-CHAR_BIT| + $CHAR_MAX$ Macro |crv-CHAR_MAX| + $CHAR_MIN$ Macro |crv-CHAR_MIN| + $INT_MAX$ Macro |crv-INT_MAX| + $INT_MIN$ Macro |crv-INT_MIN| + $LONG_LONG_MAX$ Macro |crv-LONG_LONG_MAX| + $LONG_LONG_MIN$ Macro |crv-LONG_LONG_MIN| + $LONG_MAX$ Macro |crv-LONG_MAX| + $LONG_MIN$ Macro |crv-LONG_MIN| + $MB_LEN_MAX$ Macro |crv-MB_LEN_MAX| + $SCHAR_MAX$ Macro |crv-SCHAR_MAX| + $SCHAR_MIN$ Macro |crv-SCHAR_MIN| + $SHRT_MAX$ Macro |crv-SHRT_MAX| + $SHRT_MIN$ Macro |crv-SHRT_MIN| + $UCHAR_MAX$ Macro |crv-UCHAR_MAX| + $UINT_MAX$ Macro |crv-UINT_MAX| + $ULONG_LONG_MAX$Macro |crv-ULONG_LONG_MAX| + $ULONG_MAX$ Macro |crv-ULONG_MAX| + $USHRT_MAX$ Macro |crv-USHRT_MAX| + + +------------------------------------------------------------------------------ +II.10.1 Range of Integer Type *crv-libLHRange* + +Each signed integer type has a pair of macros which give the smallest and +largest values that it can hold. Each unsigned integer type has one such +macro, for the maximum value; the minimum value is, of course, zero. + +The values of these macros are all integer constant expressions. The MAX and +MIN macros for$char$and$short int$types have values of type$int$. The MAX and +MIN macros for the other types have values of the same type described by +the macro - thus,$ULONG_MAX$has type$unsigned long int$. + +SCHAR_MIN Macro *crv-SCHAR_MIN* +SCHAR_MAX Macro *crv-SCHAR_MAX* +--------------- +minimum / maximum value that can be represented by a$signed char$ + + +UCHAR_MAX Macro *crv-UCHAR_MAX* +--------------- +maximum value that can be represented by an$unsigned char$ + + +CHAR_MIN Macro *crv-CHAR_MIN* +CHAR_MAX Macro *crv-CHAR_MAX* +-------------- +minimum / maximum value that can be represented by a$char$ + + +SHRT_MIN Macro *crv-SHRT_MIN* +SHRT_MAX Macro *crv-SHRT_MAX* +-------------- +minimum / maximum value that can be represented by a$signed short int$ + + +USHRT_MAX Macro *crv-USHRT_MAX* +--------------- +maximum value that can be represented by an$unsigned short int$ + + +INT_MIN Macro *crv-INT_MIN* +INT_MAX Macro *crv-INT_MAX* +------------- +minimum / maximum value that can be represented by a$signed int$ + +UINT_MAX Macro *crv-UINT_MAX* +-------------- +maximum value that can be represented by an$unsigned int$ + + +LONG_MIN Macro *crv-LONG_MIN* +LONG_MAX Macro *crv-LONG_MAX* +-------------- +minimum / maximum value that can be represented by a$signed long int$ + + +ULONG_MAX Macro *crv-ULONG_MAX* +--------------- +maximum value that can be represented by an$unsigned long int$ + + +LONG_LONG_MIN Macro *crv-LONG_LONG_MIN* +LONG_LONG_MAX Macro *crv-LONG_LONG_MAX* +------------------- +minimum / maximum value that can be represented by a$signed long long int$ + + +ULONG_LONG_MAX Macro *crv-ULONG_LONG_MAX* +-------------------- +maximum value that can be represented by an$unsigned long long int$ + + + + +------------------------------------------------------------------------------ +II.10.2 Width of Type *crv-libLHWidth* + +CHAR_BIT Macro *crv-CHAR_BIT* +-------------- +this is the number of bits in a$char$- eight, on most systems. The value +has type$int$. + + + +------------------------------------------------------------------------------ +II.10.3 Conversion and Properties *crv-libLHConv* + +A characteristic of each multibyte character set is the maximum number of +bytes that can be necessary to represent one character. This information +is quite important when writing code that uses the conversion functions. + +MB_LEN_MAX Macro *crv-MB_LEN_MAX* +---------------- +Specifies the maximum number of bytes in the multibyte sequence for a single +character in any of the supported locales. This is a compile-time constant. + + + + +============================================================================== +II.11 <local.h> Localization *crv-libLocalH* + +This header defines macros and declares functions for setting local specific +things. + +Quicklink: + $LC_ALL$ Macro |crv-LC_ALL| + $LC_COLLATE$ Macro |crv-LC_COLLATE| + $LC_CTYPE$ Macro |crv-LC_CTYPE| + $LC_MONETARY$ Macro |crv-LC_MONETARY| + $LC_NUMERIC$ Macro |crv-LC_NUMERIC| + $lconf$ Type |crv-lconf| + $localeconf()$ Func |crv-localeconv| + $setlocale()$ Func |crv-setlocale| + + +------------------------------------------------------------------------------ +II.11.1 Categories *crv-libLocHCat* + +The purposes that locales serve are grouped into categories, so that a user +or a program can choose the locale for each category independently. +The following macro names are both an environment variable that +a user can set, and a macro name that can be used as an argument +to$setlocale()$. +Additional macro definitions beginning with LC_ followed by uppercase letters +my be specified by the compiler. + + +LC_COLLATE Macro *crv-LC_COLLATE* +---------------- +This category applies to collation of strings (functions$strcoll()$and +$strxfrm()$). + + +LC_CTYPE Macro *crv-LC_CTYPE* +-------------- +This category applies to classification and conversion of characters, and to +multibyte and wide characters. + + +LC_MONETARY Macro *crv-LC_MONETARY* +----------------- +This category applies to formatting monetary values. + + +LC_NUMERIC Macro *crv-LC_NUMERIC* +---------------- +This category applies to formatting numeric values that are not monetary. + + +LC_ALL Macro *crv-LC_ALL* +------------ +This is not an environment variable; it is only a macro that can be use with +$setlocale()$to set a single locale for all purposes. Setting this environment +variable overwrites all selections by the other LC_* variables. + + + +------------------------------------------------------------------------------ +II.11.2 Standard Locales *crv-libLocHLoc* + +There are two standard locales: + +"C" +This is the standard C locale. The attributes and behavior it provides are +specified in the ISO C standard. This is the default. +For "C" the members of the$lconf$structure have the following values: > + char *decimal_point // "." + char *mon_decimal_point // "" + char *thousands_sep // "" + char *mon_thousands_sep // "" + char *grouping // "" + char *mon_grouping // "" + char int_frac_digits // CHAR_MAX + char frac_digits // CHAR_MAX + char *currency_symbol // "" + char *int_curr_symbol // "" + char p_cs_precedes // CHAR_MAX + char n_cs_precedes // CHAR_MAX + char int_p_cs_precedes // CHAR_MAX + char int_n_cs_precedes // CHAR_MAX + char p_sep_by_space // CHAR_MAX + char n_sep_by_space // CHAR_MAX + char int_p_sep_by_space // CHAR_MAX + char int_n_sep_by_space // CHAR_MAX + char *positive_sign // "" + char *negative_sign // "" + char p_sign_posn // CHAR_MAX + char n_sign_posn // CHAR_MAX + char int_p_sign_posn // CHAR_MAX + char int_n_sign_posn // CHAR_MAX +An empty string or$CHAR_MAX$indicates that the value is not available +in this local. + +"" +The empty name says to select a locale based on environment variables, +see categories (|crv-libLocHCat|). + + + +------------------------------------------------------------------------------ +II.11.3 Information Structure *crv-libLocHInfo* + + +lconf Type *crv-lconf* +---------- +$lconf$is a structure giving information about numeric and monetary notation. +According to standard C this structure must have at least the following +elements. +If a member of the structure has type$char$, and the value is$CHAR_MAX$, +it means that the current locale has no value for that parameter. + + +$char *decimal_point$ *crv-decimal_point* +$char *mon_decimal_point$ *crv-mon_decimal_point* +These are the decimal-point separators used in formatting non-monetary and +monetary quantities, respectively. + + +$char *thousands_sep$ *crv-thousands_sep* +$char *mon_thousands_sep$ *crv-mon_thousands_sep* +These are the separators used to delimit groups of digits to the left of the +decimal point in formatting non-monetary and monetary quantities, +respectively. + + +$char *grouping$ *crv-grouping* +$char *mon_grouping$ *crv-mon_grouping* +These are strings that specify how to group the digits to the left of the +decimal point.$grouping$applies to non-monetary quantities and$mon_grouping$ +applies to monetary quantities. Use either$thousands_sep$or$mon_thousands_sep$ +to separate the digit groups. + +Each member of these strings is to be interpreted as an integer value of type +$char$. Successive numbers (from left to right) give the sizes of successive +groups (from right to left, starting at the decimal point.) The last member +is either 0, in which case the previous member is used over and over again +for all the remaining groups, or$CHAR_MAX$, in which case there is no more +grouping - or, put another way, any remaining digits form one large group +without separators. + +For example, if grouping is "\04\03\02", the correct grouping for the number +123456787654321 is 12, 34, 56, 78, 765, 4321. This uses a group of 4 digits +at the end, preceded by a group of 3 digits, preceded by groups of 2 digits +(as many as needed). With a separator of ,, the number would be printed as +12,34,56,78,765,4321. + +A value of "\03" indicates repeated groups of three digits, as normally used +in the U.S. + + +$char int_frac_digits$ *crv-int_frac_digits* +$char frac_digits$ *crv-frac_digits* +These are small integers indicating how many fractional digits (to the right +of the decimal point) should be displayed in a monetary value in international +and local formats, respectively. + + +$char *currency_symbol$ *crv-currency_symbol* +The local currency symbol for the selected locale. + + +$char *int_curr_symbol$ *crv-int_curr_symbol* +The international currency symbol for the selected locale. The value should +normally consist of a three-letter abbreviation. + + +$char p_cs_precedes$ *crv-p_cs_precedes* +$char n_cs_precedes$ *crv-n_cs_precedes* +$char int_p_cs_precedes$ *crv-int_p_cs_precedes* +$char int_n_cs_precedes$ *crv-int_n_cs_precedes* +These members are 1 if the$currency_symbol$or$int_curr_symbol$strings should +precede the value of a monetary amount, or 0 if the strings should follow +the value. The$p_cs_precedes$and$int_p_cs_precedes$members apply to positive +amounts (or zero), and the$n_cs_precedes$and$int_n_cs_precedes$members apply +to negative amounts. +The members with the$int_ prefix$apply to the$int_curr_symbol$while the other +two apply to$currency_symbol$. + + +$char p_sep_by_space$ *crv-p_sep_by_space* +$char n_sep_by_space$ *crv-n_sep_by_space* +$char int_p_sep_by_space$ *crv-int_p_sep_by_space* +$char int_n_sep_by_space$ *crv-int_n_sep_by_space* +These members are 1 if a space should appear between the$currency_symbol$ +or$int_curr_symbol$strings and the amount, or 0 if no space should appear. +The$p_sep_by_space$and$int_p_sep_by_space$members apply to positive amounts +(or zero), and the$n_sep_by_space$and$int_n_sep_by_space$members apply to +negative amounts. +The members with the$int_ prefix$apply to the$int_curr_symbol$while the other +two apply to$currency_symbol$. There is one specialty with +the$int_curr_symbol$though. Since all legal values contain a space at the +end the string one either$printf()$this space (if the currency symbol must +appear in front and must be separated) or one has to avoid printing this +character at all (especially when at the end of the string). + + +$char *positive_sign$ *crv-positive_sign* +$char *negative_sign$ *crv-negative_sign* +These are strings used to indicate positive (or zero) and negative monetary +quantities, respectively. + + +$char p_sign_posn$ *crv-p_sign_posn* +$char n_sign_posn$ *crv-n_sign_posn* +$char int_p_sign_posn$ *crv-int_p_sign_posn* +$char int_n_sign_posn$ *crv-int_n_sign_posn* +These members are small integers that indicate how to position the sign for +nonnegative and negative monetary quantities, respectively. (The string used +by the sign is what was specified with$positive_sign$or$negative_sign$.) +The possible values are as follows: + +0 The currency symbol and quantity should be surrounded by parentheses. + +1 Print the sign string before the quantity and currency symbol. + +2 Print the sign string after the quantity and currency symbol. + +3 Print the sign string right before the currency symbol. + +4 Print the sign string right after the currency symbol. + +CHAR_MAX "Unspecified". Both members have this value in the standard C +locale. + +The members with the$int_ prefix$apply to the$int_curr_symbol$while the other +two apply to$currency_symbol$. + + + +------------------------------------------------------------------------------ +II.11.4 Functions *crv-libLocHFunc* + + +setlocale() Function *crv-setlocale* +-------------------- +Synopsis~ + $#include <locale.h>$ + $char *setlocale(int category, const char *locale);$ + +Return~ +see description + +Description~ +This function sets the current locale for category$category$to$locale$. + +If category is$ LC_ALL$, this specifies the locale for all purposes. The other +possible values of$category$specify an single purpose +(see Categories |crv-libLocHCat| ). + +This function can also be used to find out the current locale by passing a null +pointer as the$locale$argument. In this case, a string is returned that is the +name of the locale currently selected for category$category$. + +The string returned should not be modified. + +When the current locale for category$LC_ALL$is read, the value encodes the +entire combination of selected locales for all categories. + +It is not guaranteed that the returned pointer remains valid over time, so a +copy must be made. + +When the$locale$argument is not a null pointer, the string returned reflects +the newly-modified locale. + +If an empty string for$locale$is specified, this means to read the appropriate +environment variable and use its value to select the locale for$category$. + +If a nonempty string is given for$locale$, then the locale of that name is +used if possible. + +If an invalid locale name is specified,$setlocale()$returns a null pointer +and leaves the current locale unchanged. + + + +localeconf() Function *crv-localeconv* +--------------------- +Synopsis~ + $#include <locale.h>$ + $struct lconv *localeconv(void);$ + +Return~ +pointer to structure$lconv$, representing the current local settings + +Description~ +This function returns a pointer to the structure$lconv$whose components +contain information about how numeric and monetary values should be +formatted in the current locale. + + + + +============================================================================== +II.12 <math.h> Mathematics *crv-libMathH* + +This header file defines macros and declares functions that allow to do +mathematics. + +Quicklink: + $acos()$ Func |crv-acos| + $acosf()$ Func |crv-acosf| + $acosh()$ Func |crv-acosh| + $acoshf()$ Func |crv-acoshf| + $acoshl()$ Func |crv-acoshl| + $acosl()$ Func |crv-acosl| + $asin()$ Func |crv-asin| + $asinf()$ Func |crv-asinf| + $asinh()$ Func |crv-asinh| + $asinhf()$ Func |crv-asinhf| + $asinhl()$ Func |crv-asinhl| + $asinl()$ Func |crv-asinl| + $atan()$ Func |crv-atan| + $atanf()$ Func |crv-atanf| + $atanh()$ Func |crv-atanh| + $atanhf()$ Func |crv-atanhf| + $atanhl()$ Func |crv-atanhl| + $atanl()$ Func |crv-atanl| + $atan2()$ Func |crv-atan2| + $atan2f()$ Func |crv-atan2f| + $atan2l()$ Func |crv-atan2l| + $cbrt()$ Func |crv-cbrt| + $cbrtf()$ Func |crv-cbrtf| + $cbrtl()$ Func |crv-cbrtl| + $ceil()$ Func |crv-ceil| + $ceilf()$ Func |crv-ceilf| + $ceill()$ Func |crv-ceill| + $copysign()$ Func |crv-copysign| + $copysignf()$ Func |crv-copysignf| + $copysignl()$ Func |crv-copysignl| + $cos()$ Func |crv-cos| + $cosf()$ Func |crv-cosf| + $cosh()$ Func |crv-cosh| + $coshf()$ Func |crv-coshf| + $coshl()$ Func |crv-coshl| + $cosl()$ Func |crv-cosl| + $erf()$ Func |crv-erf| + $erff()$ Func |crv-erff| + $erfl()$ Func |crv-erfl| + $erfc()$ Func |crv-erfc| + $erfcf()$ Func |crv-erfcf| + $erfcl()$ Func |crv-erfcl| + $exp2()$ Func |crv-exp2| + $exp2f()$ Func |crv-exp2f| + $exp2l()$ Func |crv-exp2l| + $exp()$ Func |crv-exp| + $expf()$ Func |crv-expf| + $expl()$ Func |crv-expl| + $expm1()$ Func |crv-expm1| + $expm1f()$ Func |crv-expm1f| + $expm1l()$ Func |crv-expm1l| + $fabs()$ Func |crv-fabs| + $fabsf()$ Func |crv-fabsf| + $fabsl()$ Func |crv-fabsl| + $fdim()$ Func |crv-fdim| + $fdimf()$ Func |crv-fdimf| + $fdiml()$ Func |crv-fdiml| + $floor()$ Func |crv-floor| + $floorf()$ Func |crv-floorf| + $floorl()$ Func |crv-floorl| + $fmin()$ Func |crv-fmin| + $fminf()$ Func |crv-fminf| + $fminl()$ Func |crv-fminl| + $fma()$ Func |crv-fma| + $fmaf()$ Func |crv-fmaf| + $fmal()$ Func |crv-fmal| + $fmax()$ Func |crv-fmax| + $fmaxf()$ Func |crv-fmaxf| + $fmaxl()$ Func |crv-fmaxl| + $fmod()$ Func |crv-fmod| + $fmodf()$ Func |crv-fmodf| + $fmodl()$ Func |crv-fmodl| + $FP_FAST_FMA$ Macro |crv-FP_FAST_FMA| + $FP_FAST_FMAF$ Macro |crv-FP_FAST_FMAF| + $FP_FAST_FMAL$ Macro |crv-FP_FAST_FMAL| + $FP_ILOGB0$ Macro |crv-FP_ILOGB0| + $FP_ILOGBNAN$ Macro |crv-FP_ILOGBNAN| + $frexp()$ Func |crv-frexp| + $frexpf()$ Func |crv-frexpf| + $frexpl()$ Func |crv-frexpl| + $hypot()$ Func |crv-hypot| + $hypotf()$ Func |crv-hypotf| + $hypotl()$ Func |crv-hypotl| + $ilogb()$ Func |crv-ilogb| + $ilogbf()$ Func |crv-ilogbf| + $ilogbl()$ Func |crv-ilogbl| + $isfinite()$ Macro |crv-isfinite| + $isgreater()$ Macro |crv-isgreater| + $isgreaterequal()$Macro |crv-isgreaterequal| + $isinf()$ Macro |crv-isinf| + $isless()$ Macro |crv-isless| + $islessequal()$ Macro |crv-islessequal| + $islessgreater()$ Macro |crv-islessgreater| + $isnan()$ Macro |crv-isnan| + $isnormal()$ Macro |crv-isnormal| + $isunordered()$ Macro |crv-isunordered| + $ldexp()$ Func |crv-ldexp| + $ldexpf()$ Func |crv-ldexpf| + $ldexpl()$ Func |crv-ldexpl| + $lgamma()$ Func |crv-lgamma| + $lgammaf()$ Func |crv-lgammaf| + $lgammal()$ Func |crv-lgammal| + $log()$ Func |crv-log| + $logf()$ Func |crv-logf| + $logl()$ Func |crv-logl| + $log10()$ Func |crv-log10| + $log10f()$ Func |crv-log10f| + $log10l()$ Func |crv-log10l| + $log1p()$ Func |crv-log1p| + $log1pf()$ Func |crv-log1pf| + $log1pl()$ Func |crv-log1pl| + $log2()$ Func |crv-log2| + $log2f()$ Func |crv-log2f| + $log2l()$ Func |crv-log2l| + $logb()$ Func |crv-logb| + $logbf()$ Func |crv-logbf| + $logbl()$ Func |crv-logbl| + $lrint()$ Func |crv-lrint| + $lrintf()$ Func |crv-lrintf| + $lrintl()$ Func |crv-lrintl| + $llrint()$ Func |crv-llrint| + $llrintf()$ Func |crv-llrintf| + $llrintl()$ Func |crv-llrintl| + $lround()$ Func |crv-lround| + $lroundf()$ Func |crv-lroundf| + $lroundl()$ Func |crv-lroundl| + $llround()$ Func |crv-llround| + $llroundf()$ Func |crv-llroundf| + $llroundl()$ Func |crv-llroundl| + $modf()$ Func |crv-modf| + $modff()$ Func |crv-modff| + $modfl()$ Func |crv-modfl| + $nan()$ Func |crv-nan| + $nanf()$ Func |crv-nanf| + $nanl()$ Func |crv-nanl| + $nearbyint()$ Func |crv-nearbyint| + $nearbyintf()$ Func |crv-nearbyintf| + $nearbyintl()$ Func |crv-nearbyintl| + $nextafter()$ Func |crv-nextafter| + $nextafterf()$ Func |crv-nextafterf| + $nextafterl()$ Func |crv-nextafterl| + $nexttoward()$ Func |crv-nexttoward| + $nexttowardf()$ Func |crv-nexttowardf| + $nexttowardl()$ Func |crv-nexttowardl| + $pow()$ Func |crv-pow| + $powf()$ Func |crv-powf| + $powl()$ Func |crv-powl| + $remainder()$ Func |crv-remainder| + $remainderf()$ Func |crv-remainderf| + $remainderl()$ Func |crv-remainderl| + $remquo()$ Func |crv-remquo| + $remquof()$ Func |crv-remquof| + $remquol()$ Func |crv-remquol| + $rint()$ Func |crv-rint| + $rintf()$ Func |crv-rintf| + $rintl()$ Func |crv-rintl| + $round()$ Func |crv-round| + $roundf()$ Func |crv-roundf| + $roundl()$ Func |crv-roundl| + $scalbn()$ Func |crv-scalbn| + $scalbnf()$ Func |crv-scalbnf| + $scalbnl()$ Func |crv-scalbnl| + $scalbln()$ Func |crv-scalbln| + $scalblnf()$ Func |crv-scalblnf| + $scalblnl()$ Func |crv-scalblnl| + $signbit()$ Macro |crv-signbit| + $signgam$ Var |crv-signgam| + $sin()$ Func |crv-sin| + $sinf() $ Func |crv-sinf| + $sinh()$ Func |crv-sinh| + $sinhf()$ Func |crv-sinhf| + $sinhl()$ Func |crv-sinhl| + $sinl()$ Func |crv-sinl| + $sqrt()$ Func |crv-sqrt| + $sqrtf()$ Func |crv-sqrtf| + $sqrtl()$ Func |crv-sqrtl| + $tan()$ Func |crv-tan| + $tanf()$ Func |crv-tanf| + $tanh()$ Func |crv-tanh| + $tanhf()$ Func |crv-tanhf| + $tanhl()$ Func |crv-tanhl| + $tanl()$ Func |crv-tanl| + $tgamma()$ Func |crv-tgamma| + $tgammaf()$ Func |crv-tgammaf| + $tgammal()$ Func |crv-tgammal| + $trunc()$ Func |crv-trunc| + $truncf()$ Func |crv-truncf| + $truncl()$ Func |crv-truncl| + + + +------------------------------------------------------------------------------ +II.12.1 Error Conditions *crv-libMHErr* + +All functions declared in$<math.h>$do handle errors in a very similar way. + +If an argument is outside the domain over a function is defined a domain +error occurs, then$errno$is set to$EDOM$. The value that the function returns +is implementation specific. + +If the result of a function cannot be represented in the type of return value, +a range error occurs. +If the result overflows, the function returns the value of the macro +$HUGE_VAL$, with the same sign as the correct value of the function; +$errno$is set to$ERANGE$. + +If the result underflows, the function returns 0; whether or not$errno$is +set to$ERANGE$is implementation-defined. + + +HUGE_VAL Macro *crv-HUGE_VAL* +HUGE_VALF Macro *crv-HUGE_VALF* +HUGE_VALL Macro *crv-HUGE_VALL* +--------------- +This macro expands to a positive$double$constant. On machines that use +IEEE 754 floating point format,$HUGE_VAL$is infinity. On other machines, +it's typically the largest positive number that can be represented. +$HUGE_VALF$and$HUGE_VALL$are the analogs for$float$and$long double$. + + + +------------------------------------------------------------------------------ +II.12.2 Classification Macros *crv-libMHClass* + + +fpclassify() Macro *crv-fpclassify* +------------------ +Synopsis~ + $#include <math.h>$ + $int fpclassify(float-type x;$ + +Return~ +FP_NAN +The floating-point number x is "Not a Number" + +FP_INFINITE +The value of x is either plus or minus infinity. + +FP_ZERO +The value of x is zero. + +FP_SUBNORMAL +Numbers whose absolute value is too small to be represented in the normal +format are represented in an alternate, denormalized format +(see |crv-dtFormatsFPBasics|) + +FP_NORMAL +This value is returned for all other values of x. It indicates that there +is nothing special about the number. + +Description~ +This is a generic macro which works on all floating-point types. +It classifies its argument as NaN, infinite, normal, subnormal, zero or into +another implementation-defined category. + + + +isfinite() Macro *crv-isfinite* +---------------- +Synopsis~ + $#include <math.h>$ + $int isfinite(float-type x);$ + +Return~ +0: x is not finite +else x is finite + +Description~ +This is a generic macro which works on all floating-point types. +This macro returns a nonzero value if x is finite: not plus or minus infinity, +and not NaN. It is equivalent to + $(fpclassify (x) != FP_NAN && fpclassify (x) != FP_INFINITE)$ + + + +isnormal() Macro *crv-isnormal* +---------------- +Synopsis~ + $#include <math.h>$ + $int isnormal(float-type x);$ + +Return~ +0: x is not normal +else x is normal + +Description~ +This is a generic macro which works on all floating-point types. +This macro returns a nonzero value if x is finite and normalized. +It is equivalent to + $(fpclassify (x) == FP_NORMAL)$ + + + +isnan() Macro *crv-isnan* +------------- +Synopsis~ + $#include <math.h>$ + $int isnan(float-type x);$ + +Return~ +0: x is not NaN +else x is NaN + +Description~ +This is a generic macro which works on all floating-point types. +This macro returns a nonzero value if x is NaN. It is equivalent to + $(fpclassify (x) == FP_NAN)$ + + + +isinf() Macro *crv-isinf* +------------- +Synopsis~ + $#include <math.h>$ + $int isinf(float-type x);$ + +Return~ +0: x is not infinite +else x is infinite + +Description~ +This is a generic macro which works on all floating-point types. +This macro returns a nonzero value if x is infinte. It is equivalent to + $(fpclassify (x) == FP_INFINITE)$ +~ + + + +------------------------------------------------------------------------------ +II.12.3 Comparison Macros *crv-libMHCmp* + +All macros below are generic macros that work on all floating-point types. + + +isgreater() Macro *crv-isgreater* +----------------- +Synopsis~ + $#include <math.h>$ + $int isgreater(float-type x, float-type y);$ + +Return~ +0: x is not greater y +else x is greater y + +Description~ +This macro determines whether the argument x is greater than y. +It is equivalent to (x) > (y), but no exception is raised if x or y are NaN. + + + +isgreaterequal() Macro *crv-isgreaterequal* +---------------------- +Synopsis~ + $#include <math.h>$ + $int isgreaterequal(float-type x, float-type y);$ + +Return~ +0: x is not greater or equal y +else x is greater or equal y + +Description~ +This macro determines whether the argument x is greater than or equal to y. +It is equivalent to (x) >= (y), but no exception is raised if x or y are NaN. + + + +isless() Macro *crv-isless* +-------------- +Synopsis~ + $#include <math.h>$ + $int isless(float-type x, float-type y);$ + +Return~ +0: x is not less y +else x is less y + +Description~ +This macro determines whether the argument x is less than y. It is equivalent +to (x) < (y), but no exception is raised if x or y are NaN. + + + +islessequal() Macro *crv-islessequal* +------------------- +Synopsis~ + $#include <math.h>$ + $int islessequal(float-type x, float-type y);$ + +Return~ +0: x is not less or equal y +else x is less or equal y + +Description~ +This macro determines whether the argument x is less than or equal to y. It is +equivalent to (x) <= (y), but no exception is raised if x or y are NaN. + + + +islessgreater() Macro *crv-islessgreater* +--------------------- +Synopsis~ + $#include <math.h>$ + $int islessgreater(float-type x, float-type y);$ + +Return~ +0: x is not less or greater y +else x is less or greater y + +Description~ +This macro determines whether the argument x is less or greater than y. It is +equivalent to (x) < (y) || (x) > (y) (although it only evaluates x and y +once), but no exception is raised if x or y are NaN. +This macro is not equivalent to x != y, because that expression is true if x +or y are NaN. + + + +isunordered() Macro *crv-isunordered* +------------------- +Synopsis~ + $#include <math.h>$ + $int isunordered(float-type x, float-type y);$ + +Return~ +0: x and y are not unordered +else x or y is unordered + +Description~ +This macro determines whether its arguments are unordered. In other words, +it is true if x or y are NaN, and false otherwise. + + + +------------------------------------------------------------------------------ +II.12.4 Trigonometric *crv-libMHTrig* + + +asin() Functions *crv-asin* *crv-asinf* *crv-asinl* +---------------- +Synopsis~ + $#include <math.h>$ + $double asin(double x);$ + $float asinf(float x);$ + $long double asinl(long double x);$ + +Return~ +range -PI/2...+PI/2 + +Description~ +These functions compute the arc sine of x. The value is in units of radians. +The arc sine function is defined mathematically only over the domain -1 to 1. +If x is outside the domain, asin signals a domain error. + + + +acos() Functions *crv-acos* *crv-acosf* *crv-acosl* +---------------- +Synopsis~ + $#include <math.h>$ + $double acos(double x);$ + $float acosf(float x);$ + $long double acosl(long double x);$ + +Return~ +range 0...PI + +Description~ +These functions compute the arc cosine of x. The value is in units of radians. +The arc cosine function is defined mathematically only over the domain -1 to +1. If x is outside the domain, acos signals a domain error. + + +atan() Functions *crv-atan* *crv-atanf* *crv-atanl* +---------------- +Synopsis~ + $#include <math.h>$ + $double atan(double x);$ + $float atanf(float x);$ + $long double atanl(long double x);$ + +Return~ +range -PI/2...+PI/2 + +Description~ +These functions compute the arc tangent of x. The value is in units of +radians. + + +atan2() Functions *crv-atan2* *crv-atan2f* *crv-atan2l* +----------------- +Synopsis~ + $#include <math.h>$ + $double atan2(double x);$ + $float atan2f(float x);$ + $long double atan2l(long double x);$ + +Return~ +range -PI...+PI +If both x and y are zero, atan2 returns zero. + +Description~ +This function computes the arc tangent of y/x, but the signs of both arguments +are used to determine the quadrant of the result, and x is permitted to be +zero. The return value is given in radians. + +If x and y are coordinates of a point in the plane, atan2 returns the signed +angle between the line from the origin to that point and the x-axis. +Thus, atan2 is useful for converting Cartesian coordinates to polar +coordinates. + + + +sin() Functions *crv-sin* *crv-sinf* *crv-sinl* +--------------- +Synopsis~ + $#include <math.h>$ + $double sin(double x);$ + $float sinf(float x);$ + $long double sinl(long double x);$ + +Return~ +range -1...+1 + +Description~ +These functions return the sine of x, where x is given in radians. + + +cos() Functions *crv-cos* *crv-cosf* *crv-cosl* +--------------- +Synopsis~ + $#include <math.h>$ + $double cos(double x);$ + $float cosf(float x);$ + $long double cosl(long double x);$ + +Return~ +range -1...+1 + +Description~ +These functions return the cosine of x, where x is given in radians. + + +tan() Functions *crv-tan* *crv-tanf* *crv-tanl* +--------------- +Synopsis~ + $#include <math.h>$ + $double tan(double x);$ + $float tanf(float x);$ + $long double tanl(long double x);$ + +Return~ +tangent of x + +Description~ +These functions return the tangent of x, where x is given in radians. +Mathematically, the tangent function has singularities at odd multiples of +PI/2. If the argument x is too close to one of these singularities,$tan()$ +will signal overflow. + + + +------------------------------------------------------------------------------ +II.12.5 Hyperbolic *crv-libMHHyper* + + +sinh() Functions *crv-sinh* *crv-sinhf* *crv-sinhl* +---------------- +Synopsis~ + $#include <math.h>$ + $double sinh(double x);$ + $float sinhf(float x);$ + $long double sinhl(long double x);$ + +Return~ +hyperbolic sine of x + +Description~ +These functions return the hyperbolic sine of x, defined mathematically as +(exp(x) - exp(-x)) / 2. They may signal overflow if x is too large. + + + +cosh() Functions *crv-cosh* *crv-coshf* *crv-coshl* +---------------- +Synopsis~ + $#include <math.h>$ + $double cosh(double x);$ + $float coshf(float x);$ + $long double coshl(long double x);$ + +Return~ +hyperbolic cosine of x + +Description~ +These function return the hyperbolic cosine of x, defined mathematically as +(exp(x) + exp(-x)) / 2. They may signal overflow if x is too large. + + + +tanh() Functions *crv-tanh* *crv-tanhf* *crv-tanhl* +---------------- +Synopsis~ + $#include <math.h>$ + $double tanh(double x);$ + $float tanhf(float x);$ + $long double tanhl(long double x);$ + +Return~ +hyperbolic tangent of x + +Description~ +These functions return the hyperbolic tangent of x, defined mathematically as +sinh(x) / cosh(x). They may signal overflow if x is too large. + + + +asinh() Functions *crv-asinh* *crv-asinhf* *crv-asinhl* +----------------- +Synopsis~ + $#include <math.h>$ + $double asinh(double x);$ + $float asinhf(float x);$ + $long double asinhl(long double x);$ + +Return~ +inverse hyperbolic sine of x + +Description~ +These functions return the inverse hyperbolic sine of x. + + + +acosh() Functions *crv-acosh* *crv-acoshf* *crv-acoshl* +----------------- +Synopsis~ + $#include <math.h>$ + $double acosh(double x);$ + $float acoshf(float x);$ + $long double acoshl(long double x);$ + +Return~ +inverse hyperbolic cosine of x + +Description~ +These functions return the inverse hyperbolic cosine of x. If x is less than +1, acosh signals a domain error. + + + +atanh() Functions *crv-atanh* *crv-atanhf* *crv-atanhl* +----------------- +Synopsis~ + $#include <math.h>$ + $double atanh(double x);$ + $float atanhf(float x);$ + $long double atanhl(long double x);$ + +Return~ +inverse hyperbolic tangent of x + +Description~ +These functions return the inverse hyperbolic tangent of x. If the absolute +value of x is greater than 1,$atanh()$signals a domain error; if it is +equal to 1, it returns infinity. + + + + +------------------------------------------------------------------------------ +II.12.6 Exponential & Logarithmic *crv-libMHExpLog* + + + +exp() Functions *crv-exp* *crv-expf* *crv-expl* +--------------- +Synopsis~ + $#include <math.h>$ + $double exp(double x);$ + $float expf(float x);$ + $long double expl(long double x);$ + +Return~ +e^x + +Description~ +These functions compute e (the base of natural logarithms) raised to the +power x. If the magnitude of the result is too large to be representable, +$exp()$signals overflow. + + + +exp2() Functions *crv-exp2* *crv-exp2f* *crv-exp2l* +---------------- +Synopsis~ + $#include <math.h>$ + $double exp2(double x);$ + $float exp2f(float x);$ + $long double exp2l(long double x);$ + +Return~ +2^x + +Description~ +These functions compute 2 raised to the power x. Mathematically,$exp2(x)$is +the same as exp(x * log(2)). + + + +expm1() Functions *crv-expm1* *crv-expm1f* *crv-expm1l* +----------------- +Synopsis~ + $#include <math.h>$ + $double expm1(double x);$ + $float expm1f(float x);$ + $long double expm1l(long double x);$ + +Return~ +exp(x)-1 + +Description~ +These functions return a value equivalent to exp(x) - 1. They are computed in a +way that is accurate even if x is near zero - a case where exp(x) - 1 would be +inaccurate owing to subtraction of two numbers that are nearly equal. + + + + +ilogb() Functions *crv-ilogb* *crv-ilogbf* *crv-ilogbl* +----------------- +Synopsis~ + $#include <math.h>$ + $int ilogb(double x);$ + $int ilogbf(float x);$ + $int ilogbl(long double x);$ + +Return~ + + +Description~ +These functions are equivalent to the corresponding logb() functions except +that they return signed integer values. Since integers cannot represent +infinity and NaN,$ilogb()$instead returns an integer that can't be the +exponent of a normal floating-point number, the macros are: + +FP_ILOGB0 Macro *crv-FP_ILOGB0* + $ilogb()$returns this value if its argument is 0. The numeric value is + either$INT_MIN$or$-INT_MAX$. + +FP_ILOGBNAN Macro *crv-FP_ILOGBNAN* + $ilogb()$returns this value if its argument is NaN. The numeric value is + either$INT_MIN$or$INT_MAX$. + + + +log() Functions *crv-log* *crv-logf* *crv-logl* +--------------- +Synopsis~ + $#include <math.h>$ + $double log(double x);$ + $float logf(float x);$ + $long double logl(long double x);$ + +Return~ +see description + +Description~ +These functions compute the natural logarithm of x. If x is negative,$log()$ +signals a domain error. If x is zero, it returns negative infinity; +if x is too close to zero, it may signal overflow. + + + +log10() Functions *crv-log10* *crv-log10f* *crv-log10l* +----------------- +Synopsis~ + $#include <math.h>$ + $double log10(double x);$ + $float log10f(float x);$ + $long double log10l(long double x);$ + +Return~ +base-10 logarithm of x + +Description~ +These functions return the base-10 logarithm of x. + $log10(x)$equals$log(x) / log(10)$ + + + +log1p() Functions *crv-log1p* *crv-log1pf* *crv-log1pl* +------------------ +Synopsis~ + $#include <math.h>$ + $double log1p(double x);$ + $float log1pf(float x);$ + $long double log1pl(long double x);$ + +Return~ +log(1+x) + +Description~ +These functions returns a value equivalent to log(1 + x). They are computed +in a way that is accurate even if x is near zero. + + + +log2() Functions *crv-log2* *crv-log2f* *crv-log2l* +---------------- +Synopsis~ + $#include <math.h>$ + $double log2(double x);$ + $float log2f(float x);$ + $long double log2l(long double x);$ + +Return~ +base-2 logarithm of x + +Description~ +These functions return the base-2 logarithm of x. + $log2(x)$equals$log(x) / log(2)$ + + + +logb() Functions *crv-logb* *crv-logbf* *crv-logbl* +---------------- +Synopsis~ + $#include <math.h>$ + $double log2(double x);$ + $float log2f(float x);$ + $long double log2l(long double x);$ + +Return~ +see description + +Description~ +These functions extract the exponent of x and return it as a floating-point +value. If FLT_RADIX is two,$logb()$is equal to$floor(log2 (x))$, except it's +probably faster. +If x is denormalized,$logb()$returns the exponent x would have if it were +normalized. If x is infinity (positive or negative),$logb()$returns ∞. +If x is zero,$logb()$returns ∞. It does not signal. + + + + +frexp() Functions *crv-frexp* *crv-frexpf* *crv-frexpl* +----------------- +Synopsis~ + $#include <math.h>$ + $double frexp(double x, int *exponent);$ + $float frexpf(float x, int *exponent);$ + $long double frexpl(long double x, int *exponent);$ + +Return~ +see description + +Description~ +These functions are used to split the number value into a normalized fraction +and an exponent. +If the argument value is not zero, the return value is value times a power +of two, and is always in the range 1/2 (inclusive) to 1 (exclusive). The +corresponding exponent is stored in *exponent; the return value multiplied +by 2 raised to this exponent equals the original number value. + +For example,$frexp(12.8, &exponent)$returns 0.8 and stores 4 in exponent. + +If value is zero, then the return value is zero and zero is stored in +*exponent. + + + +ldexp() Functions *crv-ldexp* *crv-ldexpf* *crv-ldexpl* +----------------- +Synopsis~ + $#include <math.h>$ + $double ldexp(double x, int exponent);$ + $float ldexpf(float x, int exponent);$ + $long double ldexpl(long double x, int exponent);$ + +Return~ +see description + +Description~ +These functions return the result of multiplying the floating-point number +value by 2 raised to the power exponent. +(It can be used to reassemble floating-point numbers that were taken apart +by$frexp()$) . +For example,$ldexp(0.8, 4)$returns 12.8. + + + +modf() Functions *crv-modf* *crv-modff* *crv-modfl* +---------------- +Synopsis~ + $#include <math.h>$ + $double modf(double x, double *intpart);$ + $float modff(float x, float *intpart);$ + $long double modfl(long double x, long double *intpart);$ + +Return~ +stores the integer part in *intpart, and returns the fractional part + +Description~ +These functions break the argument value into an integer part and a fractional +part (between -1 and 1, exclusive). Their sum equals value. Each of the parts +has the same sign as value, and the integer part is always rounded toward zero. + +Example:$modf(2.5, &intpart)$returns 0.5 and stores 2.0 into intpart. + + + +scalbn() Functions *crv-scalbn* *crv-scalbnf* *crv-scalbnl* +------------------ +Synopsis~ + $#include <math.h>$ + $double scalbn(double x, int n);$ + $float scalbnf(float x, int n);$ + $long double scalbnl(long double x, int n);$ + +Return~ +x*FLT_RADIX^n + +Description~ +These functions compute x * FLT_RADIX^n efficiently (commonly FLT_RADIX is 2). +n is of type$int$, for type$long int$see$scalbln()$. + + + +scalbln() Functions *crv-scalbln* *crv-scalblnf* *crv-scalblnl* +------------------- +Synopsis~ + $#include <math.h>$ + $double scalbln(double x, long int n);$ + $float scalblnf(float x, long int n);$ + $long double scalblnl(long double x, long int n);$ + +Return~ +x*FLT_RADIX^n + +Description~ +These functions compute x * FLT_RADIX^n efficiently (commonly FLT_RADIX is 2). +n is of type$long int$, for type$int$see$scalbn()$. + + + +------------------------------------------------------------------------------ +II.12.7 Power & Absolute *crv-libMHPower* + + +cbrt() Functions *crv-cbrt* *crv-cbrtf* *crv-cbrtl* +---------------- +Synopsis~ + $#include <math.h>$ + $double cbrt(double x);$ + $float cbrtf(float x);$ + $long double cbrtl(long double x);$ + +Return~ +cube root of x + +Description~ +These functions return the cube root of x. They cannot fail; every +representable real value has a representable real cube root. + + + +fabs() Functions *crv-fabs* *crv-fabsf* *crv-fabsl* +---------------- +Synopsis~ + $#include <math.h>$ + $double fabs(double x);$ + $float fabsf(float x);$ + $long double fabsl(long double x);$ + +Return~ +absolute of x + +Description~ +This function returns the absolute value of the floating-point number x. + + +hypot() Functions *crv-hypot* *crv-hypotf* *crv-hypotl* +----------------- +Synopsis~ + $#include <math.h>$ + $double hypot(double x, double y);$ + $float hypotf(float x, float y);$ + $long double hypotl(long double x, long double y);$ + +Return~ +sqrt(x*x + y*y) + +Description~ +These functions return sqrt(x*x + y*y). +Normally this function is faster and more accurate than the direct formula. + + + +pow() Functions *crv-pow* *crv-powf* *crv-powl* +--------------- +Synopsis~ + $#include <math.h>$ + $double pow(double x, double y);$ + $float powf(float x, float y);$ + $long double powl(long double x, long double y);$ + +Return~ +x^y + +Description~ +These are general exponentiation functions, returning base raised to power +(x^y). + +Mathematically,$pow()$would return a complex number when base is negative and +power is not an integral value.$pow$can't do that, so instead it signals a +domain error.$pow$may also underflow or overflow the destination type. + + + +sqrt() Functions *crv-sqrt* *crv-sqrtf* *crv-sqrtl* +---------------- +Synopsis~ + $#include <math.h>$ + $double sqrt(double x);$ + $float sqrtf(float x);$ + $long double sqrtl(long double x);$ + +Return~ +sqrt(x) + +Description~ +These functions return the nonnegative square root of x. +If x is negative,$sqrt()$signals a domain error. Mathematically, it should +return a complex number. + + + + +------------------------------------------------------------------------------ +II.12.8 Error & Gamma *crv-libMHErrGam* + + +erf() Functions *crv-erf* *crv-erff* *crv-erfl* +--------------- +Synopsis~ + $#include <math.h>$ + $double erf(double x);$ + $float erff(float x);$ + $long double erfl(long double x);$ + +Return~ +error function of x + +Description~ +$erf()$returns the error function of x. The error function is defined as + erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(-t^2) dt + + +erfc() Functions *crv-erfc* *crv-erfcf* *crv-erfcl* +---------------- +Synopsis~ + $#include <math.h>$ + $double erf(double x);$ + $float erff(float x);$ + $long double erfl(long double x);$ + +Return~ +1 - error function of x + +Description~ +$erfc()$returns 1.0 -$erf(x)$, but computed in a fashion that avoids +round-off error when x is large. + + +lgamma() Functions *crv-lgamma* *crv-lgammaf* *crv-lgammal* +------------------ +Synopsis~ + $#include <math.h>$ + $double lgamma(double x);$ + $float lgammaf(float x);$ + $long double lgammal(long double x);$ + +Return~ +see description + +Description~ +$lgamma()$returns the natural logarithm of the absolute value of the gamma +function of x. The gamma function is defined as + + gamma(x) = integral from 0 to ∞ of t^(x-1) e^-t dt + + *crv-signgam* +The sign of the gamma function is stored in the global variable$signgam$, +which is declared in$<math.h>$. It is 1 if the intermediate result was +positive or zero, or -1 if it was negative. + +To compute the real gamma function $tgamma()$can be used or the values as +can be computed as follows: + + lgam = lgamma(x); + gam = signgam*exp(lgam); + + +The gamma function has singularities at the non-positive integers.$lgamma()$ +will raise the zero divide exception if evaluated at a singularity. + + + +tgamma() Functions *crv-tgamma* *crv-tgammaf* *crv-tgammal* +------------------ +Synopsis~ + $#include <math.h>$ + $double tgamma(double x);$ + $float tgammaf(float x);$ + $long double tgammal(long double x);$ + +Return~ +see description + +Description~ +$tgamma()$applies the gamma function to x. The gamma function is defined as + gamma (x) = integral from 0 to ∞ of t^(x-1) e^-t dt + + + + +------------------------------------------------------------------------------ +II.12.9 Nearest Integer *crv-libMHNear* + + +ceil() Functions *crv-ceil* *crv-ceilf* *crv-ceill* +---------------- +Synopsis~ + $#include <math.h>$ + $double ceil(double x);$ + $float ceilf(float x);$ + $long double ceill(long double x);$ + +Return~ +x rounded upwards + +Description~ +These functions round x upwards to the nearest integer, returning that value +as a double. Thus, ceil(1.5)$ is 2.0. + + + +floor() Functions *crv-floor* *crv-floorf* *crv-floorl* +----------------- +Synopsis~ + $#include <math.h>$ + $double floor(double x);$ + $float floorf(float x);$ + $long double floorl(long double x);$ + +Return~ +x rounded downwards + +Description~ +These functions round x downwards to the nearest integer, returning that value +as a double. Thus,$floor(1.5)$is 1.0 and$floor(-1.5)$is -2.0. + + + +trunc() Functions *crv-trunc* *crv-truncf* *crv-truncl* +----------------- +Synopsis~ + $#include <math.h>$ + $double trunc(double x);$ + $float truncf(float x);$ + $long double truncl(long double x);$ + +Return~ +x rounded towards zero + +Description~ +These functions round x towards zero to the nearest integer (returned in +floating-point format). Thus,$trunc(1.5)$is 1.0 and$trunc(-1.5)$is -1.0. + + + +rint() Functions *crv-rint* *crv-rintf* *crv-rintl* +---------------- +Synopsis~ + $#include <math.h>$ + $double rint(double x);$ + $float rintf(float x);$ + $long double rintl(long double x);$ + +Return~ +x rounded according to rounding mode + +Description~ +These functions round x to an integer value according to the current rounding +mode (for modes see "II.6.3 Rounding" |crv-libFHRounding|). The default +rounding mode is to round to the nearest integer. +If x was not initially an integer, these functions raise the inexact +exception. + + + *crv-nearbyint* +nearbyint() Functions *crv-nearbyintf* *crv-nearbyintl* +--------------------- +Synopsis~ + $#include <math.h>$ + $double nearbyint(double x);$ + $float nearbyintf(float x);$ + $long double nearbyintl(long double x);$ + +Return~ +x rounded according to rounding mode + +Description~ +These functions return the same value as the$rint()$functions, but do not +raise the inexact exception if x is not an integer. + + + +round() Functions *crv-round* *crv-roundf* *crv-roundl* +----------------- +Synopsis~ + $#include <math.h>$ + $double round(double x);$ + $float roundf(float x);$ + $long double roundl(long double x);$ + +Return~ +see description + +Description~ +These functions are similar to$rint()$, but they round halfway cases away from +zero instead of to the nearest even integer. + + + +lrint() Functions *crv-lrint* *crv-lrintf* *crv-lrintl* +----------------- +Synopsis~ + $#include <math.h>$ + $long int lrint(double x);$ + $long int lrintf(float x);$ + $long int lrintl(long double x);$ + +Return~ +x rounded according to rounding mode + +Description~ +These functions are just like$rint()$, but they return a$long int$instead of +a floating-point number. + + + +llrint() Functions *crv-llrint* *crv-llrintf* *crv-llrintl* +------------------ +Synopsis~ + $#include <math.h>$ + $long long int llrint(double x);$ + $long long int llrintf(float x);$ + $long long int llrintl(long double x);$ + +Return~ +x rounded according to rounding mode + +Description~ +These functions are just like$rint()$, but they return a$long long int$instead +of a floating-point number. + + + +lround() Functions *crv-lround* *crv-lroundf* *crv-lroundl* +------------------ +Synopsis~ + $#include <math.h>$ + $long int lround(double x);$ + $long int lroundf(float x);$ + $long int lroundl(long double x);$ + +Return~ +x rounded + +Description~ +These functions are just like$round()$, but they return a$long int$instead of +a floating-point number. + + + +llround() Functions *crv-llround* *crv-llroundf* *crv-llroundl* +------------------- +Synopsis~ + $#include <math.h>$ + $long long int llround(double x);$ + $long long int llroundf(float x);$ + $long long int llroundl(long double x);$ + +Return~ +x rounded + +Description~ +These functions are just like$round()$, but they return a$long long int$ +instead of a floating-point number. + + + +------------------------------------------------------------------------------ +II.12.10 Remainder *crv-libMHRem* + + +fmod() Functions *crv-fmod* *crv-fmodf* *crv-fmodl* +---------------- +Synopsis~ + $#include <math.h>$ + $double fmod(double x, double y);$ + $float fmodf(float x, float y);$ + $long double fmodl(long double x, long double y);$ + +Return~ +see description + +Description~ +These functions compute the remainder from the division of x by. Specifically, +the return value is x - n*y, where n is the quotient of x divided by y, +rounded towards zero to an integer. Thus,$fmod(6.5, 2.3)$ returns 1.9, which +is 6.5 minus 4.6. +The result has the same sign as x and has magnitude less than the magnitude +of y. +If y is zero,$fmod()$signals a domain error. + + + *crv-remainder* +remainder() Functions *crv-remainderf* *crv-remainderl* +--------------------- +Synopsis~ + $#include <math.h>$ + $double remainder(double x, double y);$ + $float remainderf(float x, float y);$ + $long double remainderl(long double x, long double y);$ + +Return~ +see description + +Description~ +These functions are like$fmod()$except that they rounds the internal quotient +n to the nearest integer instead of towards zero to an integer. +For example,$remainder(6.5, 2.3)$returns -0.4, which is 6.5 minus 6.9. + +The absolute value of the result is less than or equal to half the absolute +value of y. The difference between$fmod(x, y)$and$remainder(x, y)$is always +either y, -y, or zero. +If denominator is zero,$remainder()$signals a domain error. + + + +remquo() Functions *crv-remquo* *crv-remquof* *crv-remquol* +------------------ +Synopsis~ + $#include <math.h>$ + $double remquo(double x, double y, int *quo);$ + $float remquof(float x, float y, int *quo);$ + $long double remquol(long double x, long double y, int *quo);$ + +Return~ +see description + +Description~ +These functions compute the same remainder as the$remainder()$functions. +In *quo they store a value whose sign is the singe of x/y and whose +magnitude is congruent modulo 2^n to the magnitude of the integral quotient +of x/y, where n is an implementation-defined integer greater or equal to 3. + + + +------------------------------------------------------------------------------ +II.12.11 Manipulating *crv-libMHMani* + + + *crv-copysign* +copysign() Functions *crv-copysignf* *crv-copysignl* +-------------------- +Synopsis~ + $#include <math.h>$ + $double copysign(double x, double y);$ + $float copysignf(float x, float y);$ + $long double copysignl(long double x, long double y);$ + +Return~ +x with sign of y + +Description~ +These functions return x but with the sign of y. They work even if x or y are +NaN or zero. Both of these can carry a sign (although not all implementations +support it). +$copysign()$never raises an exception. + + + +signbit() Macro *crv-signbit* +--------------- +Synopsis~ + $#include <math.h>$ + $int signbit(float-type x);$ + +Return~ +0: x has no negative sign +else x has negative sign + +Description~ +This is a generic macro which works on all floating-point types. +This macro returns a nonzero value if x is negative. +This is not the same as x < 0.0, because IEEE 754 floating point allows zero +to be signed. The comparison -0.0 < 0.0 is false, but$signbit(-0.0)$ will +return a nonzero value. + + + *crv-nextafter* +nextafter() Functions *crv-nextafterf* *crv-nextafterl* +--------------------- +Synopsis~ + $#include <math.h>$ + $double nextafter(double x, double y);$ + $float nextafterf(float x, float y);$ + $long double nextafetl(long double x, long double y);$ + +Return~ +see description + +Description~ +These functions return the next representable neighbor of x in the direction +towards y. The size of the step between x and the result depends on the type +of the result. If x = y the function simply returns y. If either value is +NaN, NaN is returned. Otherwise a value corresponding to the value of the +least significant bit in the mantissa is added or subtracted, depending on +the direction. +$nextafter()$will signal overflow or underflow if the result goes outside of +the range of normalized numbers. + + + *crv-nexttoward* +nexttoward() Functions *crv-nexttowardf* *crv-nexttowardl* +---------------------- +Synopsis~ + $#include <math.h>$ + $double nexttoward(double x, long double y);$ + $float nexttowardf(float x, long double y);$ + $long double nexttowardl(long double x, long double y);$ + +Return~ +see description + +Description~ +These functions are identical to the corresponding versions of$nextafter()$ +except that their second argument is a long double. + + + +nan() Functions *crv-nan* *crv-nanf* *crv-nanl* +--------------- +Synopsis~ + $#include <math.h>$ + $double nan(const char *tagp);$ + $float nanf(const char *tagp);$ + $long double nanl(const char *tagp);$ + +Return~ +NaN + +Description~ +These functions return a representation of NaN, provided that NaN is supported +by the target platform.$nan("n-char-sequence")$is equivalent to +$strtod("NAN(n-char-sequence)")$. + +The argument tagp is used in an unspecified manner. On IEEE 754 systems, there +are many representations of NaN, and tagp selects one. On other systems it may +do nothing. + + + + +------------------------------------------------------------------------------ +II.12.12 Miscellaneous *crv-libMHMisc* + + +fdim() Functions *crv-fdim* *crv-fdimf* *crv-fdiml* +---------------- +Synopsis~ + $#include <math.h>$ + $double fdim(double x, double y);$ + $float fdimf(float x, float y);$ + $long double fdiml(long double x, long double y);$ + +Return~ +positive difference + +Description~ +These functions return the positive difference between x and y. The positive +difference is x - y if x is greater than y, and 0 otherwise. +If x, y, or both are NaN, NaN is returned. + + + +fmin() Functions *crv-fmin* *crv-fminf* *crv-fminl* +---------------- +Synopsis~ + $#include <math.h>$ + $double fmin(double x, double y);$ + $float fminf(float x, float y);$ + $long double fminl(long double x, long double y);$ + +Return~ +minimum of x and y + +Description~ +These functions return the lesser of the two values x and y. It is similar to +the expression ((x) < (y) ? (x) : (y)) except that x and y are only evaluated +once. +If an argument is NaN, the other argument is returned. If both arguments are +NaN, NaN is returned. + + + +fmax() Functions *crv-fmax* *crv-fmaxf* *crv-fmaxl* +---------------- +Synopsis~ + $#include <math.h>$ + $double fmax(double x, double y);$ + $float fmaxf(float x, float y);$ + $long double fmaxl(long double x, long double y);$ + +Return~ +maximum of x and y + +Description~ +These functions return the greater of the two values x and y. +If an argument is NaN, the other argument is returned. If both arguments are +NaN, NaN is returned. + + + +fma() Functions *crv-fma* *crv-fmaf* *crv-fmal* +---------------- +Synopsis~ + $#include <math.h>$ + $double fma(double x, double y, double z);$ + $float fmaf(float x, float y, float z);$ + $long double fmal(long double x, long double y, long double z);$ + +Return~ + +Description~ +These functions perform floating-point multiply-add. This is the operation +(x * y) + z, but the intermediate result is not rounded to the destination +type. This can sometimes improve the precision of a calculation. + +This function was introduced because some processors have a special +instruction to perform multiply-add. The C compiler cannot use it directly, +because the expression x*y + z is defined to round the intermediate result. +$fma()$lets you choose when you want to round only once. + + *crv-FP_FAST_FMA* + *crv-FP_FAST_FMAF* *crv-FP_FAST_FMAL* +On processors which do not implement multiply-add in hardware,$fma$can be +very slow since it must avoid intermediate rounding. +math.h defines the symbols$FP_FAST_FMA$,$FP_FAST_FMAF$, and$FP_FAST_FMAL$ when +the corresponding version of$fma()$is no slower than the expression x*y + z. + + + + +============================================================================== +II.13 <setjmp.h> Nonlocal Jumps *crv-libSetjmpH* + +This header file provides a function, a macro and a data type to perform +nonlocal exits. Typically this is used to do an intermediate return from a +nested function call. + +Quicklink: + $jmp_buf$ Type |crv-libjmp_buf| + $longjmp()$ Func |crv-liblongjmp| + $setjmp()$ Macro |crv-libsetjmp| + + + +jmp_buf Type *crv-jmp_buf* +------------ +Objects of type$jmp_buf$hold the state information to be restored by a +nonlocal exit. The contents of a$jmp_buf$identify a specific place to return +to. + + + +setjmp() Macro *crv-setjmp* +-------------- +Synopsis~ + $#include <setjmp.h>$ + $int setjmp(jmp_buf state);$ + +Return~ +0: if normally executed +!=0: value passed to$longjmp()$ + +Description~ +When called normally,$setjmp()$stores information about the execution state of +the program in$state$and returns zero. If$longjmp()$is later used to perform +a nonlocal exit to this state,$setjmp()$returns a nonzero value. + +Calls to$setjmp()$are safe in only the following contexts: + - As the test expression of a selection or iteration statement (such as$if,$ + $switch$, or$while$). + - As one operand of a equality or comparison operator that appears as the + test expression of a selection or iteration statement. The other operand + must be an integer constant expression. + - As the operand of a unary ! operator, that appears as the test expression + of a selection or iteration statement. + - By itself as an expression statement. + +Return points are valid only during the dynamic extent of the function that +called$setjmp()$to establish them. If returned via$longjmp()$to a return point +that was established in a function that has already returned, unpredictable +and disastrous things are likely to happen. + + + +longjmp() Function *crv-longjmp* +------------------ +Synopsis~ + $#include <setjmp.h>$ + $void longjmp(jmp_buf state, int value);$ + +Return~ +none + +Description~ +This function restores current execution to the state saved in$state$, and +continues execution from the call to$setjmp()$that established that return +point. Returning from$setjmp()$by means of$longjmp()$returns the value +argument that was passed to$longjmp()$, rather than 0. +(But if value is given as 0, setjmp returns 1). + + + +============================================================================== +II.14 <signal.h> Signal Handling *crv-libSignalH* + +This header file defines macros and declares functions for handling signals. + +Quicklink: + $rais()$ Func |crv-rais| + $sig_atomic_t$ Type |crv-sig_atomic_t| + $SIG_DFL$ Macro |crv-SIG_DFL| + $SIG_ERR$ Macro |crv-SIG_ERR| + $SIG_IGN$ Macro |crv-SIG_IGN| + $SIGABRT$ Macro |crv-SIGABRT| + $SIGFPE$ Macro |crv-SIGFPE| + $SIGILL$ Macro |crv-SIGILL| + $SIGINT$ Macro |crv-SIGINT| + $signal()$ Func |crv-signal| + $SIGSEGV$ Macro |crv-SIGSEGV| + $SIGTERM$ Macro |crv-SIGTERM| + + + +------------------------------------------------------------------------------ +II.14.1 Types *crv-libSHTyp* + +sig_atomic_t Type *crv-sig_atomic_t* +----------------- +This is an integer data type. Objects of this type are always accessed +atomically. Reading and writing this data type is guaranteed to happen in a +single instruction, so there's no way for a handler to run "in the middle" +of an access. +The type sig_atomic_t is always an integer data type, but which one it is, +and how many bits it contains, may vary from machine to machine. + + + +------------------------------------------------------------------------------ +II.14.2 Signals *crv-libSHSig* + +Valid signals are: + + Signal | Description + -----------+--------------------------------------------------- + $SIGABRT$ | abnormal termination (e.g. call of$abort()$) *crv-SIGABRT* + $SIGFPE$ | arithmetic error (e.g. division by zero, *crv-SIGFPE* + | overflow) + $SIGILL$ | illegal instruction *crv-SIGILL* + $SIGINT$ | interactive attention signal (e.g. interrupt) *crv-SIGINT* + $SIGSEGV$ | invalid access to storage *crv-SIGSEGV* + $SIGTERM$ | termination request sent to the program *crv-SIGTERM* + +Other signals my be specified by the compiler. + +It depends on the machine whether this signals are generated by the system +itself.$raise()$function can be used to send them. + + + +------------------------------------------------------------------------------ +II.14.3 Functions *crv-libSHFunc* + + +signal() Function *crv-signal* +----------------- +Synopsis~ + $#include <signal.h>$ + $void (*signal(int sig, void (*handler)(int)))(int);$ + +Return~ +- pointer to previous handler, if call was successful +-$SIG_ERR$, if call failed + +Description~ +This function chooses one of three ways in which receipt of the signal$sig$is +to be handled, these ways are: + *crv-SIG_DFL* *crv-SIG_IGN* + - If the value of$handler$is$SIG_DFL$, default handling for that signal + occurs. + - If the value of$handler$is$SIG_IGN$, the signal is ignored. + - If the value of$handler$points to a function, that function is called + with the argument of the type of signal. + +For valid signals see II.14.2 (|crv-libSHSig|). + *crv-SIG_ERR* +If the call to signal is successful, then it returns a pointer to the previous +signal handler for the specified signal type. If the call fails, then$SIG_ERR$ +is returned and$errno$is set to a positive value. + + + +rais() Function *crv-rais* +--------------- +Synopsis~ + $#include <signal.h>$ + $int raise(int signum);$ + +Return~ +0: signal sent successfully +else: failed + +Description~ +The raise function sends the signal$signum$to the calling process. +About the only reason for failure would be if the value of signum is invalid. + + + + +------------------------------------------------------------------------------ +II.15 <stdarg.h> Arguments *crv-libStdargH* + +This header files defines macros which allow to handle functions with an +unknown number of arguments. +See |crv-fuDefVarPara| for an example. + +Quicklink: + $va_arg()$ Macro |crv-libva_arg| + $va_copy()$ Macro |crv-libva_copy| + $va_end()$ Macro |crv-libva_end| + $va_list$ Type |crv-libva_list| + $va_start()$ Macro |crv-libva_start| + + +va_list Type *crv-va_list* +------------ +This type is used for argument pointer variables. + + +va_start() Macro *crv-va_start* +---------------- +Synopsis~ + $#include <signal.h>$ + $void va_start(va_list ap, last-required);$ + +Return~ +none + +Description~ +This macro initializes the argument pointer variable ap to point to the first +of the optional arguments of the current function; last-required must be the +last required argument to the function. + + + +va_arg() Macro *crv-va_arg* +-------------- +Synopsis~ + $#include <signal.h>$ + $type va_arg(va_list ap, type);$ + +Return~ +value of next argument + +Description~ +This macro returns the value of the next optional argument, and modifies the +value of ap to point to the subsequent argument. Thus, successive uses of +$va_arg()$return successive optional arguments. + +The type of the value returned by$va_arg()$is$type$as specified in the call. + + + +va_end() Macro *crv-va_end* +-------------- +Synopsis~ + $#include <signal.h>$ + $void va_end(va_list ap);$ + +Return~ +none + +Description~ +This ends the use of ap. After a$va_end()$call, further$va_arg()$calls with +the same ap may not work.$va_end()$should be invoked before returning from the +function in which$va_start()$was invoked with the same ap argument. + + + +va_copy() Macro *crv-va_copy* +--------------- +Synopsis~ + $#include <signal.h>$ + $void va_copy (va_list dest, va_list src);$ + +Return~ +none + +Description~ +The$va_copy()$macro allows copying of objects of type$va_list$even if this is +not an integral type. +The copies can be used to parse the list of parameters more than once. + + + + +============================================================================== +II.16 <stdbool.h> Boolean Type *crv-libStdboolH* + + +bool Macro *crv-bool* +---------- +expands to$_Bool$ + + +true Macro *crv-true* +---------- +expands to integer constant 1 + + +false Macro *crv-false* +----------- +expands to integer constant 0 + + +__bool_true_false_are_defined Macro *crv-__bool_true_false_are_defined* +----------------------------------- +expands to integer constant 1 + + + + +============================================================================== +II.17 <stddef.h> Definitions *crv-libStddefH* + +This header file defines some macros and types (some of them are also defined +in other header files). + +Quicklink: + $prtdiff_t$ Type |crv-prtdiff_t| + $size_t$ Type |crv-size_t| + $wchar_t$ Type |crv-wchar_t| + $NULL$ Macro |crv-NULL| + $offsetof()$ Macro |crv-offsetof| + + +prtdiff_t Type *crv-prtdiff_t* +-------------- +This is the signed integer type of the result of subtracting two pointers. +For example, with the declaration$char *p1, *p2;$, the expression$p2 - p1$is +of type$ptrdiff_t$. + + +size_t Type *crv-size_t* +----------- +This is an unsigned integer type used to represent the sizes of objects. +Also declared in$<stdlib.h>$, see |crv-size_t2|. +Also declared in$<string.h>$, see |crv-size_t3|. +Also declared in$<time.h>$, see |crv-size_t4|. +Also declared in$<stdio.h>$, see |crv-size_t5|; +Also declared in$<wchar.h>$, see |crv-size_t6|. + + +wchar_t Type *crv-wchar_t* +------------ +This data type is used as the base type for wide character strings. +It's range of values can represent distinct codes for all members of the +largest extended character set specified among the supported locales. +Also declared in$<stdlib.h>$, see |crv-libwchar_t2|. +Also declared in$<wchar.h>$, see |crv-libwchar_t3|. + + +NULL Macro *crv-NULL* +---------- +Expands to an implementation-defined null pointer constant. +Also defined in$<stdlib.h>$, see |crv-NULL2|. +Also defined in$<string.h>$, see |crv-NULL3|. +Also defined in$<time.h>$, see |crv-NULL4|. +Also defined in$<stdio.h>$, see |crv-NULL5|. +Also defined in$<wchar.h>$, see |crv-NULL6|. + + + +offsetof() Macro *crv-offsetof* +---------------- +Synopsis~ + $#include <stddef.h>$ + $size_t offsetof (type, member);$ + +Return~ +offset of$member$in structure$type$ + +Description~ +This expands to an integer constant expression that is the offset of the +structure member named$member$in the structure type$type$. + + + +============================================================================== +II.18 <stdint.h> Integer Type *crv-libStdintH* + +This header file declares a set of integer types having specified widths and +defines a set of macros to handle them. + +Types are defined in the following categories: + - integer types with a certain exact width + - integer types having at least a certain width + - fastest integer types having at least a certain width + - integer types wide enough to hold pointers + - integer types having greatest width + + +------------------------------------------------------------------------------ +II.18.1 Integer Types *crv-libSdHType* + +II.18.1.1 Exact-Width *crv-libSdHTExact* +---------------------- +There are integer types representing exactly N bits. The general form is: +intN_t (signed width N bits width) +uintN_t (unsigned width N bits width) + +Common types are: + $int8_t$ $uint8_t$ *crv-int8_t* *crv-uint8_t* + $int16_t$ $uint16_t$ *crv-int16_t* *crv-uint16_t* + $int32_t$ $uint32_t$ *crv-int32_t* *crv-uint32_t* + $int64_t$ $uint64_t$ *crv-int64_t* *crv-uint64_t* +These types are optional. The compiler is free to declare others (e.g. +$int24_t$). + + +II.18.1.2 Minimum-Width *crv-libSdHTMin* +----------------------- +There are integer types with at least N bits width. The general form is: +int_leastN_t (signed with at least N bits width) +uint_leastN_t (unsigned with at least N bits width) + +Common types are: + $int_least8_t$ $uint_least8_t$ *crv-int_least8_t* + *crv-uint_least8_t* + $int_least16_t$ $uint_least16_t$ *crv-int_least16_t* + *crv-uint_least16_t* + $int_least32_t$ $uint_least32_t$ *crv-int_least32_t* + *crv-uint_least32_t* + $int_least64_t$ $uint_least64_t$ *crv-int_least64_t* + *crv-uint_least64_t* + +These types are required. Others may be declared by the compiler. + + +II.18.1.3 Fastest Minimum-Width *crv-libSdHTFast* +------------------------------- +These integer types allow the fastest access while having at least N bits. +The general form is: +int_fastN_t (fast signed with at least N bits width) +uint_fastN_t (fast unsigned with at least N bits width) + +Common types are: + $int_fast8_t$ $uint_fast8_t$ *crv-int_fast8_t* + *crv-uint_fast8_t* + $int_fast16_t$ $uint_fast16_t$ *crv-int_fast16_t* + *crv-uint_fast16_t* + $int_fast32_t$ $uint_fast32_t$ *crv-int_fast32_t* + *crv-uint_fast32_t* + $int_fast64_t$ $uint_fast64_t$ *crv-int_fast64_t* + *crv-uint_fast64_t* + +These types are required. Others may be declared by the compiler. + + +II.18.1.4 Greatest-Width *crv-libSdHTGreat* +------------------------ +These integer types have the widest range possible on the platform on which +they are being used. + $intmax_t$ (signed) *crv-intmax_t* + $uintmax_t$ (unsigned) *crv-uintmax_t* +These types are required. + + +II.18.1.5 Hold Pointer *crv-libSdHTPtr* +---------------------- +These integer types are wide enough to store a pointer of type$void$. + $intptr_t$ (signed) *crv-intptr_t* + $uintptr_t$ (unsigned) *crv-uintptr_t* + +These types are optional. + + + +------------------------------------------------------------------------------ +II.18.2 Limits *crv-libSdHTLim* + *crv-__STDC_LIMIT_MACROS* +The following macros specify the minimum and maximum of the types declared +in$<stdint.h>$. They are defined only if$__STDC_LIMIT_MACROS$is defined before +including$<stdint.h>$. + +II.18.2.1 Exact-Width *crv-libSdHLExact* +--------------------- +Signed integer minimum: + INTN_MIN, N is the number of bits + Value: -2^(N-1) + Common macros: + $INT8_MIN$ *crv-INT8_MIN* + $INT16_MIN$ *crv-INT16_MIN* + $INT32_MIN$ *crv-INT32_MIN* + $INT64_MIN$ *crv-INT64_MIN* + +Signed integer maximum: + INTN_MAX, N is the number of bits + Value: 2^(N-1) - 1 + Common macros: + $INT8_MAX$ *crv-INT8_MAX* + $INT16_MAX$ *crv-INT16_MAX* + $INT32_MAX$ *crv-INT32_MAX* + $INT64_MAX$ *crv-INT64_MAX* + +Unsigned integer minimum: + is always 0 + +Unsigned integer maximum: + UINTN_MAX, N is the number of bits + Value: 2^N - 1 + Common macros: + $UINT8_MAX$ *crv-UINT8_MAX* + $UINT16_MAX$ *crv-UINT16_MAX* + $UINT32_MAX$ *crv-UINT32_MAX* + $UINT64_MAX$ *crv-UINT64_MAX* + + + +II.18.2.2 Minimum-Width *crv-libSdHLMin* +----------------------- +Signed integer minimum: + INT_LEASTN_MIN, N is the number of bits + Value: <= -2^(N-1) + Common macros: + $INT_LEAST8_MIN$ *crv-INT_LEAST8_MIN* + $INT_LEAST16_MIN$ *crv-INT_LEAST16_MIN* + $INT_LEAST32_MIN$ *crv-INT_LEAST32_MIN* + $INT_LEAST64_MIN$ *crv-INT_LEAST64_MIN* + +Signed integer maximum: + INT_LEASTN_MAX, N is the number of bits + Value: >= 2^(N-1) - 1 + Common macros: + $INT_LEAST8_MAX$ *crv-INT_LEAST8_MAX* + $INT_LEAST16_MAX$ *crv-INT_LEAST16_MAX* + $INT_LEAST32_MAX$ *crv-INT_LEAST32_MAX* + $INT_LEAST64_MAX$ *crv-INT_LEAST64_MAX* + +Unsigned integer minimum: + is always 0 + +Unsigned integer maximum: + UINT_LEASTN_MAX, N is the number of bits + Value: >= 2^N - 1 + Common macros: + $UINT_LEAST8_MAX$ *crv-UINT_LEAST8_MAX* + $UINT_LEAST16_MAX$ *crv-UINT_LEAST16_MAX* + $UINT_LEAST32_MAX$ *crv-UINT_LEAST32_MAX* + $UINT_LEAST64_MAX$ *crv-UINT_LEAST64_MAX* + + + +II.18.2.3 Fastest Minimum-Width *crv-libSdHLFast* +------------------------------- +Signed integer minimum: + INT_FASTN_MIN, N is the number of bits + Value: <= -2^(N-1) + Common macros: + $INT_FAST8_MIN$ *crv-INT_FAST8_MIN* + $INT_FAST16_MIN$ *crv-INT_FAST16_MIN* + $INT_FAST32_MIN$ *crv-INT_FAST32_MIN* + $INT_FAST64_MIN$ *crv-INT_FAST64_MIN* + +Signed integer maximum: + INT_FASTN_MAX, N is the number of bits + Value: >= 2^(N-1) - 1 + Common macros: + $INT_FAST8_MAX$ *crv-INT_FAST8_MAX* + $INT_FAST16_MAX$ *crv-INT_FAST16_MAX* + $INT_FAST32_MAX$ *crv-INT_FAST32_MAX* + $INT_FAST64_MAX$ *crv-INT_FAST64_MAX* + +Unsigned integer minimum: + is always 0 + +Unsigned integer maximum: + UINT_FASTN_MAX, N is the number of bits + Value: >= 2^N - 1 + Common macros: + $UINT_FAST8_MAX$ *crv-UINT_FAST8_MAX* + $UINT_FAST16_MAX$ *crv-UINT_FAST16_MAX* + $UINT_FAST32_MAX$ *crv-UINT_FAST32_MAX* + $UINT_FAST64_MAX$ *crv-UINT_FAST64_MAX* + + + +II.18.2.4 Greatest-Width *crv-libSdHLGreat* +------------------------ +Minimum value of greatest-width signed integer type: +$ INTMAX_MIN$ <= -(2^63) *crv-INTMAX_MIN* + +Maximum value of greatest-width signed integer type: +$ INTMAX_MAX$ >= 2^63 - 1 *crv-INTMAX_MAX* + +Minimum value of greatest-width unsigned integer type: + 0 +Maximum value of greatest-width unsigned integer type: +$ UINTMAX_MAX$ >= 2^64 - 1 *crv-UINTMAX_MAX* + + + +II.18.2.5 Hold Pointer *crv-libSdHLPtr* +---------------------- +Minimum value of pointer holding signed integer type: + $INTPTR_MIN$ <= -(2^15) *crv-INTPTR_MIN* + +Maximum value of pointer holding signed integer type: + $INTPTR_MAX$ >= 2^15 - 1 *crv-INTPTR_MAX* + +Minimum value of pointer holding unsigned integer type: + 0 + +Maximum value of pointer holding unsigned integer type: + $UINTPTR_MAX$ >= 2^16 - 1 *crv-UINTPTR_MAX* + + + +II.18.2.6 Others *crv-libSdHLOther* +---------------- +Limits of$ptrdiff_t$: + $PTRDIFF_MIN$ *crv-PTRDIFF_MIN* + $PTRDIFF_MAX$ *crv-PTRDIFF_MAX* + +Limits of$sig_atomic_t$: + $SIG_ATOMIC_MIN$ *crv-SIG_ATOMIC_MIN* + $SIG_ATOMIC_MAX$ *crv-SIG_ATOMIC_MAX* + +Limits of$size_t$: + $SIZE_MAX$ *crv-SIZE_MAX* + +Limits of$wchar_t$: + $WCHAR_MIN$ *crv-WCHAR_MIN* + $WCHAR_MAX$ *crv-WCHAR_MAX* + Also defined in$<wctype.h>$, see |crv-libWCHAR_MIN2|, |crv-libWCHAR_MAX2|. + +Limits of$wint_t$: + $WINT_MIN$ *crv-WINT_MIN* + $WINT_MAX$ *crv-WINT_MAX* + + + +----------------------------------------------------------------------------- +II.18.3 Macros *crv-libSdHMac* + + +INTMAX_C() Macro *crv-INTMAX_C* +---------------- +Synopsis~ + $#include <stdint.h>$ + $INTMAX_C(val);$ + +Description~ +expands to an integer constant value$val$of type$intmax_t$ + + +UINTMAX_C() Macro *crv-UINTMAX_C* +----------------- +Synopsis~ + $#include <stdint.h>$ + $UINTMAX_C(val);$ + +Description~ +expands to an integer constant value$val$of type$uintmax_t$ + + + *crv-INT8_C* *crv-INT16_C* +INTN_C() Macro *crv-INT32_C* *crv-INT64_C* +-------------- +Synopsis~ + $#include <stdint.h>$ + $INT8_C(val);$ + $INT16_C(val);$ + $INT32_C(val);$ + $INT64_C(val);$ + +Description~ +expands to an integer constant value$val$of type$int_leastN_t$(N number of +bits) + + + *crv-UINT8_C* *crv-UINT16_C* +UINTN_C() Macro *crv-UINT32_C* *crv-UINT64_C* +--------------- +Synopsis~ + $#include <stdint.h>$ + $UINT8_C(val);$ + $UINT16_C(val);$ + $UINT32_C(val);$ + $UINT64_C(val);$ + +Description~ +expands to an integer constant value$val$of type$uint_leastN_t$(N number of +bits) + + + + +============================================================================== +II.19 <stdio.h> Input/Output *crv-libStdioH* + +This header file declares types, macros and functions to perform input/output +operations. + + +------------------------------------------------------------------------------ +II.19.1 Types *crv-libSIOHType* + +Quicklink: + $size_t$ Type |crv-size_t5| + $FILE$ Type |crv-FILE| + $fpos_t$ Type |crv-fpos_t| + + +size_t Type *crv-size_t5* +----------- +This is an unsigned integer type used to represent the sizes of objects. +Also declared in$<stddef.h>$, see |crv-size_t|. +Also declared in$<string.h>$, see |crv-size_t2|. +Also declared in$<stdlib.h>$, see |crv-size_t3|. +Also declared in$<time.h>$, see |crv-size_t4|. +Also declared in$<wchar.h>$, see |crv-size_t6|. + + +FILE Type *crv-FILE* +--------- +This is the data type used to represent stream objects. A FILE object holds +all of the internal state information about the connection to the associated +file. + + +fpos_t Type *crv-fpos_t* +----------- +This is the type of an object that can encode information about the file +position of a stream. + + + + +------------------------------------------------------------------------------ +II.19.2 Macros *crv-libSIOHMac* + +Quicklink: + $_IOFBF$ Macro |crv-_IOFBF| + $_IOLBF$ Macro |crv-_IOLBF| + $_IONBF$ Macro |crv-_IONBF| + $BUFSIZ$ Macro |crv-BUFSIZ| + $BUFSIZ$ Macro |crv-BUFSIZ| + $FOPEN_MAX$ Macro |crv-FOPEN_MAX| + $FILENAME_MAX$ Macro |crv-FILENAME_MAX| + $L_tmpnam$ Macro |crv-L_tmpnam| + $NULL$ Macro |crv-NULL5| + $SEEK_SET$ Macro |crv-SEEK_SET| + $SEEK_CUR$ Macro |crv-SEEK_CUR| + $SEEK_END$ Macro |crv-SEEK_END| + $stderr$ Macro |crv-stderr| + $stdin$ Macro |crv-stdin| + $stdout$ Macro |crv-stdout| + + + +NULL Macro *crv-NULL5* +---------- +Expands to an implementation-defined null pointer constant. +Also defined in$<stddef.h>$, see |crv-libNULL|. +Also defined in$<stdlib.h>$, see |crv-libNULL2|. +Also defined in$<string.h>$, see |crv-libNULL3|. +Also defined in$<time.h>$, see |crv-libNULL4|. +Also defined in$<wchar.h>$, see |crv-libNULL6|. + + + +_IOFBF Macro *crv-_IOFBF* +_IOLBF Macro *crv-_IOLBF* +_IONBF Macro *crv-_IONBF* +------------ +This macros expand to an constant integer expression that can be used as the +mode argument to the$setvbuf()$function. + + $_IOFBF$ specifies that the stream should be fully buffered + $_IOLBF$ specifies that the stream should be line buffered + $_IONBF$ specifies that the stream should be unbuffered + + + +BUFSIZ Macro *crv-BUFSIZ* +------------ +The value of this macro is an integer constant expression that is good to use +for the size argument to$setvbuf()$. This value is guaranteed to be at least +256. + + + +EOF Macro *crv-EOF* +--------- +This is returned by a number of narrow stream functions to indicate an +end-of-file condition, or some other error situation. + + + +FOPEN_MAX Macro *crv-FOPEN_MAX* +--------------- +The value of this macro is an integer constant expression that represents the +minimum number of streams that the implementation guarantees can be open +simultaneously. + + + +FILENAME_MAX Macro *crv-FILENAME_MAX* +------------------ +The value of this macro is an integer constant expression that represents +the maximum length of a file name string. + + + +L_tmpnam Macro *crv-L_tmpnam* +-------------- +The value of this macro is an integer constant expression that represents the +minimum size of a string large enough to hold a file name generated by the +$tmpnam()$function. + + + + +SEEK_SET Macro *crv-SEEK_SET* +SEEK_CUR Macro *crv-SEEK_CUR* +SEEK_END Macro *crv-SEEK_END* +-------------- +These are integer constants which are used as the whence argument to the +fseek() or fseeko() functions. + + $SEEK_SET$ specifies that the offset provided is relative to the beginning + of the file + $SEEK_CUR$ specifies that the offset provided is relative to the current + file position + $SEEK_END$ specifies that the offset provided is relative to the end of the + file + + +TMP_MAX Macro *crv-TMP_MAX* +------------- +This is the maximum number of unique filenames that the function$tmpnam()$can +generate. + + + +stderr Macro *crv-stderr* +stdin Macro *crv-stdin* +stdout Macro *crv-stdout* +------------ +These macros expand to pointers to$FILE$types which correspond to the standard +error, standard input and standard output streams. These streams are text +streams. + +The standard input stream is the normal source of input for the program. +The standard output stream is the normal source of output from the program. +The standard error stream is used for error messages and diagnostics issued +by the program. + + + +------------------------------------------------------------------------------ +II.19.3 Streams and Files *crv-libSIOHStrmFile* + +Streams provide a higher-level interface between program and input/output +device. There are two types of streams: text and binary streams. + +Text and binary streams differ in several ways: + + - The data read from a text stream is divided into lines which are + terminated by newline ('\n') characters, while a binary stream is simply a + long series of characters. + A text stream might on some systems fail to handle lines more than 254 + characters long (including the terminating newline character). + + - On some systems, text files can contain only printing characters, + horizontal tab characters, and newlines, and so text streams may not + support other characters. However, binary streams can handle any character + value. + + - Space characters that are written immediately preceding a newline + character in a text stream may disappear when the file is read in again. + + - More generally, there need not be a one-to-one mapping between characters + that are read from or written to a text stream, and the characters in the + actual file. + +Binary streams transfers data without changing (1:1 copy). + +On some systems text and binary streams use different file formats, the only +way to read or write "an ordinary file of text" that can work with other +text-oriented programs is through a text stream. + +At startup of a program there are three text streams available: standard +input, standard output and standard error. See |crv-libstdout| for further +information. + + +Files are associated with streams. A file must be opened to be used. One of +the attributes of an open file is its file position that keeps track of where +in the file the next character is to be read or written. +The file position is normally set to the beginning of the file when it is +opened, and each time a character is read or written, the file position is +incremented, so access to the file is normally sequential. + +Ordinary files permit read or write operations at any position within the +file. Some other kinds of files may also permit this. Files which do permit +this are sometimes referred to as random-access files. The file position +can be changed using the$fseek()$function on a stream. + +Streams that are opened for append access are treated specially for output: +output to such files is always appended sequentially to the end of the +file, regardless of the file position. However, the file position is still +used to control where in the file reading is done. + +Each opening of a file creates a separate file position. Thus, if a file is +opened twice - even in the same program - two streams with independent +file positions are generated. + + +An open file must be closed,$fclose()$can be used to do that. If$main()$ +returns or$exit()$is called, all opened files are closed automatically. +Other path to program termination (e.g.$abort()$) do not need to close +files (dependes on compiler). + + + +------------------------------------------------------------------------------ +II.19.4 File Operations *crv-libSIOHFOp* + + +remove() Function *crv-remove* +----------------- +Synopsis~ + $#include <stdio.h>$ + $int remove(const char *file_name);$ + +Return~ +0: successful +nonzero: failed + +Description~ +Remove the file (unlink it) with name$*file$points to. Any subsequent attempt +to open it again will fail. If the file is currently open, then the result is +implementation-defined. + + + +rename() Function *crv-rename* +----------------- +Synopsis~ + $#include <stdio.h>$ + $int rename(const char *oldname, const char *newname);$ + +Return~ +0: successful +else: failed + +Description~ +This function renames the file$oldname$to$newname$. The file formerly +accessible under the name$oldname$is afterwards accessible as$newname$instead. +If the new file exists before renaming, then the result is +implementation-defined. + + + +tmpfile() Function *crv-tmpfile* +------------------ +Synopsis~ + $#include <stdio.h>$ + $FILE *tmpfile(void);$ + +Return~ +NULL: failed +else: pointer to stream of the created file + +Description~ +This function creates a temporary binary file for update mode, as if by +calling$fopen()$with mode "wb+". The file is deleted automatically when it is +closed or when the program terminates. + + + +tmpnam() Function *crv-tmpnam* +----------------- +Synopsis~ + $#include <stdio.h>$ + $char *tmpnam(char *result);$ + +Return~ +NULL: failed +else: pointer to name of file + +Description~ +This function constructs and returns a valid file name that does not refer to +any existing file. If the$result$argument is a null pointer, the return value +is a pointer to an internal static string, which might be modified by +subsequent calls. Otherwise, the$result$argument should be a pointer to an +array of at least$L_tmpnam$characters, and the result is written into that +array. In this case the value of the argument is returned. +Each call of$tmpnam()$generates a different name, up to$TMP_MAX$times. + + + + +------------------------------------------------------------------------------ +II.19.5 File Access *crv-libSIOHFAcc* + + +fclose() Function *crv-fclose* +----------------- +Synopsis~ + $#include <stdio.h>$ + $int fclose(FILE *stream);$ + +Return~ +0: success +EOF: failed + +Description~ +This function causes$stream$to be closed and the connection to the +corresponding file to be broken. Any buffered output is written and any +buffered input is discarded. + + + +fflush() Function *crv-fflush* +----------------- +Synopsis~ + $#include <stdio.h>$ + $int fflush(FILE *stream);$ + +Return~ +0: success +EOF: failed + +Description~ +This function causes any buffered output on$stream$to be delivered to the +file. If$stream$is a null pointer, then$fflush()$causes buffered output on all +open output streams to be flushed. + + + +fopen() Function *crv-fopen* +---------------- +Synopsis~ + $#include <stdio.h>$ + $FILE *fopen(const char *file_name, const char *opentype);$ + +Return~ +NULL: failed +else: pointer to stream of opened file + +Description~ +This function opens a stream for I/O to the file$file_name$, and returns a +pointer to the stream. +The$opentype$argument is a string that controls how the file is opened and +specifies attributes of the resulting stream. It must begin with one of the +following sequences of characters, other may follow (implementation-defined): + + Mode | Description + ------------+-------------------------------------------------------------- + $r$ | open text file for reading + $w$ | truncate to zero length or create text file for writing + $a$ | append; open or create text file for writing at end-of-file + $rb$ | open binary file for reading + $wb$ | truncate to zero length or create binary file for writing + $ab$ | append; open or create binary file for writing at end-of-file + $r+$ | open text file for reading and writing + $w+$ | truncate to zero length or create text file for reading and + | writing + $a+$ | append; open or create text file for reading and writing, + | writing at end-of-file + $r+b or rb+$| open binary file for reading and writing + $w+b or wb+$| truncate to zero length or create binary file for reading + | and writing + $a+b or ab+$| append; open or create binary file for reading and writing, + | writing at end-of-file + + + + +freopen() Function *crv-freopen* +------------------ +Synopsis~ + $#include <stdio.h>$ + $FILE *freopen(const char *file_name, const char *opentype, FILE *stream);$ + +Return~ +NULL: failed +else: pointer to stream of opened file + +Description~ +This function is like a combination of$fclose()$and$fopen()$. It first closes +the stream referred to by$stream$, ignoring any errors that are detected in +the process. Then the file named by$file_name$is opened with mode$opentype$as +for$fopen()$, and associated with the same stream object$stream$. + +This is traditionally been used to connect a standard stream such as$stdin$ +with a file. + + + +setbuf() Function *crv-setbuf* +----------------- +Synopsis~ + $#include <stdio.h>$ + $void setbuf(FILE *stream, char *buf);$ + +Return~ +none + +Description~ +If$buf$is a null pointer, the effect of this function is equivalent to calling +$setvbuf()$with a mode argument of$_IONBF$. Otherwise, it is equivalent to +calling$setvbuf()$with$buf$, and a mode of$_IOFBF$and a size argument of +$BUFSIZ$. + +This function is provided for compatibility with old code; use$setvbuf()$in +all new programs. + + + +setvbuf() Function *crv-setvbuf* +------------------ +Synopsis~ + $#include <stdio.h>$ + $int setvbuf(FILE *stream, char *buf, int mode, size_t size);$ + +Return~ +0: success +nonzero: failed + +Description~ +This function is used to specify that the stream$stream$should have the +buffering mode$mode$, which can be: + +$_IOFBF$ full buffering |crv-lib_IOFBF| +$_IOLBF$ line buffering |crv-lib_IOLBF| +$_IONBF$ unbuffered input/output |crv-lib_IONBF| + +If a null pointer as the$buf$argument is specified, then$setvbuf()$allocates +a buffer itself. This buffer will be freed when closing the stream. + +Otherwise,$buf$should be a character array that can hold at least$size$ +characters. This space should not be freed as long as the stream remains open +and this array remains its buffer. + + + + +------------------------------------------------------------------------------ +II.19.6 Formatted Input/Output *crv-libSIOHIO* + + +II.19.6.1 Format Control *crv-libSIOHIOFormat* +------------------------ + +II.19.6.1.1 Output, printf() *crv-libSIOHIOFout* +----------------------------- +The family of printf() functions write output to a stream, under control of +the format string. The format specifies how subsequent arguments are converted +to output. +A format string for output has the following syntax: + $%[flags][width][.precision][modifier]type$ + +[flags] control convertion (optional) +[width] number of characters to output (optional) +[.precision] precision of number (optional) +[modifier] overrides size (type) of argument (optional) +[type] type of conversion (required) + + +[flag] control convertion (optional) + + zero or more flags may be specified + + flag | Description + -------+--------------------------------------------------------------------- + $-$ | value is left-justified (default is right-justified) + $+$ | forces to show sign of value (+ or -) + | default is to show only - for negative values, overrules space + space | print " " in front of positive value, print - for negative value + $#$ | convert to alternative form: + | $o$ increase precision to force the first digit to be a zero + | + | $x$or$X$ nonzero result will have prefix "0x" or "0X" + | + | $a$,$A$, + | $e$,$E$, + | $f$,$F$, + | $g$or$G$ result will always have decimal point + | + | $g$or$G$ trailing zeros are not removed + | + $0$ | for $d, i, o, u, x, X, a, A, e, E, f, F, g, G$conversions leading + | zeros are used to pad to the field width instead of spaces + + +[width] number of characters to output (optional) + This is a decimal integer specifying the minimum field width. If the normal + conversion produces fewer characters than this, the field is padded with + spaces to the specified width. If the normal conversion produces more + characters than this, the field is not truncated. Normally, the output is + right-justified within the field. + A field width of$*$may be specified. This means that the next argument + in the argument list (before the actual value to be printed) is used as the + field width. The value must be an integer of type$int$. If the value is + negative, this means to set the$-$flag and to use the absolute value as + the field width. + +[.precision] precision of number (optional) + The precision specifies the number of digits to be written for the numeric + conversions. If the precision is specified, it consists of a period ($.$) + followed optionally by a decimal integer (which defaults to zero if + omitted). + + A precision of$*$may be specified. This means that the next argument + in the argument list (before the actual value to be printed) is used as the + precision. The value must be an integer of type$int$, and is ignored if it + is negative. + If$*$is specified for both the field width and precision, the field width + argument precedes the precision argument. + + + precision | Description + -----------+----------------------------------------------------------------- + (none) | default precision: + | 1 for$d, i, o, u, x, X$types. Precision gives the minimum number + | of digits to appear. + | 6 for$f, F, e, E$types. Precision gives the number of digits to + | appear after decimal point. + | For$g, G$types all digits are printed. + | For$s$type all characters of the string are printed, not + | including the terminating null character. + | For$a, A$and$FLT_RADIX$of 2: precision is sufficient for an + | exact representation of the value. + | For$a, A$and$FLT_RADIX$not equal to 2: precision is sufficient + | to distinguish values of type$double$. + | + $.$or$.0$ | For$d, i, o, u, x, X$types the default precision is used, unless + | the value is 0, then no characters are printed. + | For$f, F, e, E$types no decimal-point and no decimal-digits are + | printed.. + | For$g, G$types precision is assumed to be 1. + | For$s$type nothing is printed. + | For$a, A$types no decimal-point and no decimal-digits appear. + | + $.N$ | For$d, i, o, u, x, X$types. At least N digits appear, if + | necessary output is expanded with leading zeros. + | For$f, F, e, E$types. N digits appear after decimal point. + | For$g, G$types N digits are printed. + | For$s$type a maximum of N characters of the string are printed, + | not including the terminating null character. + | For$a, A$types N specifies the number of digits after decimal + | point. + | + + + +[modifier] overrides size (type) of argument (optional) + The modifier character is used to specify the data type of the corresponding + argument if it differs from the default type. + + + modifier | Description + ----------+------------------------------------------------------------------ + $hh$ | Specifies that the argument is a$signed char$or$unsigned char$, + | as appropriate. A$char$argument is converted to an$int$or + |$unsigned int$by the default argument promotions anyway, but this + | modifier says to convert it back to a$char$again. + | + $h$ | Specifies that the argument is a$short int$or$unsigned short int$ + | as appropriate. A$short$argument is converted to an$int$or + |$unsigned int$by the default argument promotions anyway, but this + | modifier says to convert it back to a$short$again. + | + $l$ | Specifies that the argument is a$long int$or$unsigned long int$, + | as appropriate. Two l characters is like the L modifier, below + | If used with$%c$or$%s$the corresponding parameter is considered + | as a wide character or wide character string respectively. + | + $ll$ | Specifies that a following$d, i, o, u, x, X$applies to a + |$long long int$or$unsigned long long int$argument; or that a + |$n$applies to a pointer to$long long int$. + | + $L$ | Specifies that a following$a, A, e, E, f, F, g, G$conversion + | specifier applies to a$long double$argument. + | + $j$ | Specifies that a following$d, i, o, u, x, X$applies to$intmax_t$ + | or$uintmax_t$, or that a following$n$applies to pointer to + |$intmax_t$. + | + $t$ | Specifies that a following$d, i, o, u, x, X$applies to a + |$ptrdiff_t$or the corresponding unsigned integer type argument; + | or that a$n$applies to a pointer to a$ptrdiff_t$argument. + | + $z$ | Specifies that the following$d, i, o, u, x, X$applies to a + |$size_t$or the corresponding singed integer type argument; + | or that a$n$applies to a pointer to a signed integer type + | corresponding to$size_t$argument. + + +[type] type of conversion (required) + + The conversion specifier specifies the conversion to be applied. + + type | Description + --------+------------------------------------------------------------------ + $ d, i$ | type$signed int$, output decicmal, style [-]dddd + $o$ | type$unsigned int$, output octal, style: dddd + $u$ | type$unsigned int$, output decimal, style dddd + $x$ | type$unsigned int$, output hexadecimal, style dddd using a...f + $X$ | type$unsigned int$, output hexadecimal, style dddd using A...F + $f, F$ | type$double$, output decimal, style [-]ddd.ddd + $e$ | type$double$, output decimal, style [-]d.ddde+/-dd + $E$ | type$double$, output decimal, style [-]d.dddE+/-dd + $g$ | type$double$, printed as type$e$if exponent is less than -4 + | or greater than or equal to the precision. Otherwise$f$is used. + $G$ | type$double$, printed as type$E$if exponent is less than -4 + | or greater than or equal to the precision. Otherwise$F$is used. + $a$ | type$double$, style [-]0xh.hhhhp+/-d + | h: hexadecimal digit 0...9, a...f + | d: decimal digit + $A$ | type$double$, style [-]0Xh.hhhhP+/-d + | h: hexadecimal digit 0...9, A...F + | d: decimal digit + $c$ | no$l$modifier: type$char$, single character is printed + | with$l$modifier: type$wchar_t$, single character is printed + $s$ | no$l$modifier: pointer to array of$char$, string is printed + | with$l$modifier: pointer to array of$char$, string is printed + $p$ | type pointer to$void$, value of pointer is printed in an + | implementation-defined way + $n$ | argument is a pointer to$signed int$into which is written the + | number of characters written to the output stream so far + $%$ | a % is printed + + + + +II.19.6.1.2 Input, scanf() *crv-libSIOHIOFin* +--------------------------- +The family of scanf() functions read input from a stream, under control of +the format string. The format specifies how the input is to be stored in +the appropriate variable(s). +A white-space character may match with any whitespace character (space, tab, +carriage return, new line, vertical tab, or formfeed). +Other characters in the format string that are not part of conversion +specifications must match characters in the input stream exactly; if this is +not the case, a matching failure occurs and scanning is stopped. + +A format string for input has the following syntax: + $%[*][width][modifier]type$ + +[*] assignment suppressor (optional) +[width] maximum number of characters to be read (optional) +[modifier] overrides size (type) of argument (optional) +[type] type of conversion (required) + + +[*] assignment suppressor (optional) + The assignment suppressor$*$says to ignore the text read for this + specification. When scanf() finds a conversion specification that uses this + flag, it reads input as directed by the rest of the conversion + specification, but it discards this input, does not use a pointer argument, + and does not increment the count of successful assignments. + + +[width] maximum number of characters to be read (optional) + This is a decimal integer that specifies the maximum field width. Reading of + characters from the input stream stops either when this maximum is reached + or when a non-matching character is found, whichever happens first. Then + what was read so far is converted and stored in the variable. + + Most conversions discard initial whitespace characters (those that don't are + explicitly documented), and these discarded characters don't count towards + the maximum field width. String input conversions store a null character + to mark the end of the input; the maximum field width does not include this + terminator. + + +[modifier] overrides size (type) of argument (optional) + The modifier character is used to specify the data type of the corresponding + argument if it differs from the default type. + + + modifier | Description + ----------+------------------------------------------------------------------ + $hh$ | Specifies that a following$d, i, o, u, x, X, n$conversion applies + | to an argument with type pointer to$signed char$or + | $unsigned char$ + | + $h$ | Specifies that a following$d, i, o, u, x, X, n$conversion applies + | to an argument with type pointer to$short int$or$unsigned short$. + | + $l$ | Specifies that a following$d, i, o, u, x, X, n$conversion applies + | to an argument with type pointer to$long int$or + |$unsigned long int$; or that a following$a, A, e, E, f, F, g, G$ + | converstion applies to an argument with type pointer to$double$; + | or that a following$c, s, [$conversion applies to an argument + | with type pointer to$wchar_t$. + | + $ll$ | Specifies that a following$d, i, o, u, x, X, n$argument applies + | to an argument with type pointer to$long long int$or + | $unsigned long long int$. + | + $L$ | Specifies that a following$a, A, e, E, f, F, g, G$conversion + | applies to an argument of type pointer to$long double$argument. + | + $j$ | Specifies that a following$d, i, o, u, x, X, n$conversion applies + | to an argument with type pointer to$intmax_t$or$uintmax_t$. + | + $t$ | Specifies that a following$d, i, o, u, x, X, n$conversion applies + | to an argument of type pointer to$ptrdiff_t$or the corresponding + | unsigned integer type. + | + $z$ | Specifies that a following$d, i, o, u, x, X, n$conversion applies + | to an argument of type pointer to$size_t$or the corresponding + | singed integer type. + + + +[type] type of conversion (required) + + The conversion specifier specifies the conversion to be applied. + + type | Description + --------+-------------------------------------------------------------------- + $ d $ | type$signed int$, matches an optionally signed integer written + | in decimal + | + $i$ | type$signed int$, matches an optionally signed integer in any of + | the formats that the C language defines for specifying an integer + | constant. The based used depends on the first two characters: + | - first character 1...9, then base 10 (decimal) + | - first digit 0, followed by 0..7, then base 8 (octal) + | - first digit 0, followed by x or X, then base 16 (hexadecimal) + | + $o$ | type$unsigned int$, matches octal numbers (digits 0...7 only) + | + $u$ | type$unsigned int$, matches decimal numbers (digits 0...9 only) + | + $x, X$ | type$unsigned int$, matches hexadecimal numbers (characters 0...9, + | a-f, A-F only). The number may be prefixed with 0x or 0X. + | + $f, F$ | matches an optionally signed floating point number + $e, E$ | + $g, G$ | + $a, A$ | + | + $c$ | Matches a string of one or more characters; the number of + | characters read is controlled by the maximum field width given for + | the conversion. No null character is appended. + | no$l$modifier: argument is of type pointer to array of$char$ + | with$l$modifier: argument is of type pointer to array of$wchar_t$ + | + $s$ | Matches a sequence of non-white-space characters. A null + | character is appended. + | no$l$modifier: argument is of type pointer to array of$char$ + | with$l$modifier: argument is of type pointer to array of$wchar_t$ + | + $ [...]$| Matches a nonempty sequence of characters from a set of expected + | characters enclosed in brackets [...] (scanset). If the first + | character is a circumflex (^), the selection is inverted, in that + | case the scanset contains all characters that do NOT appear in the + | list between [^ and ]. + | A null character is appended. + | no$l$modifier: argument is of type pointer to array of$char$ + | with$l$modifier: argument is of type pointer to array of$wchar_t$ + | + $p$ | Matches a pointer value in the same implementation-defined format + | used by the$%p$output conversion for printf(). + | + $n$ | No input is consumed. It records the number of characters read so + | far by this call. Argument is a pointer to$signed int$into which is + | written the number of characters read from the input stream so far. + | + $%$ | Matches a single %. No conversion or assignment occurs. + + + + +II.19.6.2 Functions *crv-libSIOHIOFunc* +------------------- + +Quicklink + $printf()$ Func |crv-printf| + $fprintf()$ Func |crv-fprintf| + $sprintf()$ Func |crv-sprintf| + $snprintf()$ Func |crv-snprintf| + $vfprintf()$ Func |crv-vfprintf| + $vprintf()$ Func |crv-vprintf| + $vsprintf()$ Func |crv-vsprintf| + $vsnprintf()$Func |crv-vsnprintf| + + $fscanf()$ Func |crv-fscanf| + $scanf()$ Func |crv-scanf| + $sscanf()$ Func |crv-sscanf| + $vfscanf()$ Func |crv-vfscanf| + $vscanf()$ Func |crv-vscanf| + $vsscanf()$ Func |crv-vsscanf| + + + +printf() Function *crv-printf* +----------------- +Synopsis~ + $#include <stdio.h>$ + $int printf(const char *format, ...);$ + +Return~ +<0: output error occurred +>= 0: number of transmitted characters + +Description~ +This function prints the optional arguments under the control of the format +string$format$to the standard output stream$stdout$. +For format string see |crv-libSIOHIOFout|. + + + +fprintf() Function *crv-fprintf* +------------------ +Synopsis~ + $#include <stdio.h>$ + $int fprintf(FILE *stream, const char *format, ...);$ + +Return~ +<0: output error occurred +>= 0: number of transmitted characters + +Description~ +This function is equivalent to$printf()$, except that the output is written +to the stream$stream$instead of$stdout$. + + + +sprintf() Function *crv-sprintf* +------------------ +Synopsis~ + $#include <stdio.h>$ + $int sprintf(char *s, const char *format, ...);$ + +Return~ +<0: error occurred +number of characters stored in array, not including terminating null character + +Description~ +This is like$printf()$, except that the output is stored in the character +array$s$instead of written to a stream. A null character is written to mark +the end of the string. + + + +snprintf() Function *crv-snprintf* +------------------- +Synopsis~ + $#include <stdio.h>$ + $int snprintf(char *s, size_t size, const char *format, ...);$ + +Return~ +<0: error occurred +The return value is the number of characters which would be generated for the +given input, excluding the trailing null. If this value is greater or equal +to$size$, not all characters from the result have been stored in$s$. + +Description~ +This function is similar to$sprintf()$, except that the$size$argument +specifies the maximum number of characters to produce. The trailing null +character is counted towards this limit. + + + +vprintf() Function *crv-vprintf* +------------------ +Synopsis~ + $#include <stdarg.h>$ + $#include <stdio.h>$ + $int vprintf(const char *format, va_list ap);$ + +Return~ +<0: output error occurred +>= 0: number of transmitted characters + +Description~ +This function is similar to$printf()$except that, instead of taking a variable +number of arguments directly, it takes an argument list pointer$ap$, which +must have been initialized by the$va_start()$macro. The$vprintf()$function +does not invoke the$va_end()$macro. + + + +vfprintf() Function *crv-vfprintf* +------------------- +Synopsis~ + $#include <stdarg.h>$ + $#include <stdio.h>$ + $int vfprintf(FILE *stream, const char *format, va_list ap);$ + +Return~ +<0: output error occurred +>= 0: number of transmitted characters + +Description~ +This function is similar to$fprintf()$except that, instead of taking a +variable number of arguments directly, it takes an argument list pointer$ap$, +which must have been initialized by the$va_start()$macro. The$vfprintf()$ +function does not invoke the$va_end()$macro. + + + +vsprintf() Function *crv-vsprintf* +------------------- +Synopsis~ + $#include <stdarg.h>$ + $#include <stdio.h>$ + $int vsnprintf(char *s, size_t size, const char *format, va_list ap);$ + +Return~ +<0: error occurred +number of characters stored in array, not including terminating null character + +Description~ +This function is similar to$sprintf()$except that, instead of taking a +variable number of arguments directly, it takes an argument list pointer$ap$, +which must have been initialized by the$va_start()$macro. The$vsprintf()$ +function does not invoke the$va_end()$macro. + + + +vsnprintf() Function *crv-vsnprintf* +-------------------- +Synopsis~ + $#include <stdarg.h>$ + $#include <stdio.h>$ + $int vsnprintf(char *s, size_t size, const char *format, va_list ap);$ + +Return~ +<0: error occurred +The return value is the number of characters which would be generated for the +given input, excluding the trailing null. If this value is greater or equal +to$size$, not all characters from the result have been stored in$s$. + +Description~ +This function is similar to$snprintf()$except that, instead of taking a +variable number of arguments directly, it takes an argument list pointer$ap$, +which must have been initialized by the$va_start()$macro. The$vsnprintf()$ +function does not invoke the$va_end()$macro. + + + +scanf() Function *crv-scanf* +---------------- +Synopsis~ + $#include <stdio.h>$ + $int scanf(const char *format, ...);$ + +Return~ +The return value is the number of successful assignments. If there is a match +error, this number can be fewer than provided. If an input error occurs +before any matches are performed, then$EOF$is returned. + +Description~ +This function reads formatted input from the standard input stream$stdin$under +the control of the format string$format$. The optional arguments are pointers +to the places which receive the resulting values. +For format string see |crv-libSIOHIOFin|. + + + +fscanf() Function *crv-fscanf* +----------------- +Synopsis~ + $#include <stdio.h>$ + $int fscanf(FILE *stream, const char *format, ...);$ + +Return~ + +Description~ +This function is equivalent to$scanf()$, except that the input is read from +the stream$stream$instead of$stdin$. + + + +sscanf() Function *crv-sscanf* +----------------- +Synopsis~ + $#include <stdio.h>$ + $int sscanf(const char *s, const char *format, ...);$ + +Return~ + +Description~ +This function is similar to$scanf()$, except that the characters are taken +from the null-terminated string$s$instead of from$stdin$. Reaching the end of +the string is treated as an end-of-file condition. + + +vscanf() Function *crv-vscanf* +----------------- +Synopsis~ + $#include <stdio.h>$ + $int vscanf(const char *format, va_list ap);$ + +Return~ + +Description~ +This function is similar to$scanf()$except that, instead of taking a +variable number of arguments directly, it takes an argument list pointer$ap$, +which must have been initialized by the$va_start()$macro. The$vscanf()$ +function does not invoke the$va_end()$macro. + + + +vfscanf() Function *crv-vfscanf* +------------------ +Synopsis~ + $#include <stdio.h>$ + $int vfscanf(FILE *stream, const char *format, va_list ap);$ + +Return~ + +Description~ +This function is similar to$fscanf()$except that, instead of taking a +variable number of arguments directly, it takes an argument list pointer$ap$, +which must have been initialized by the$va_start()$macro. The$vfscanf()$ +function does not invoke the$va_end()$macro. + + + +vsscanf() Function *crv-vsscanf* +------------------ +Synopsis~ + $#include <stdio.h>$ + $int vsscanf(const char *s, const char *format, va_list ap);$ + +Return~ + +Description~ +This function is similar to$sscanf()$except that, instead of taking a +variable number of arguments directly, it takes an argument list pointer$ap$, +which must have been initialized by the$va_start()$macro. The$vsscanf()$ +function does not invoke the$va_end()$macro. + + + + + +------------------------------------------------------------------------------ +II.19.7 Character Input/Output *crv-libSIOHCIO* + +This section describes functions for performing character-oriented input and +output. + +Quicklink: + $fgetc()$ Func |crv-fgetc| + $fgets()$ Func |crv-fgets| + $fputc()$ Func |crv-fputc| + $fputs()$ Func |crv-fputs| + $getc()$ Macro |crv-getc| + $getchar()$ Func |crv-getchar| + $gets()$ Func |crv-gets| + $putc()$ Macro |crv-putc| + $putchar()$ Func |crv-putchar| + $puts()$ Func |crv-puts| + $ungetc()$ Func |crv-ungetc| + + + +fgetc() Function *crv-fgetc* +---------------- +Synopsis~ + $#include <stdio.h>$ + $int fgetc(FILE *stream);$ + +Return~ +character read from stream +error or end-of-file:$EOF$ + +Description~ +This function reads the next character as an$unsigned char$from the stream +$stream$and returns its value, converted to an$int$. If an end-of-file +condition or read error occurs,$EOF$is returned instead. + + + +fgets() Function *crv-fgets* +---------------- +Synopsis~ + $#include <stdio.h>$ + $char *fgets(char *s, int count, FILE *stream);$ + +Return~ +If the system is already at end of file when fgets() is called, then the +contents of the array$s$are unchanged and a null pointer is returned. +A null pointer is also returned if a read error occurs. Otherwise, the +return value is the pointer$s$. + +Description~ +This function reads characters from the stream$stream$up to and including a +newline character and stores them in the string$s$, adding a null character +to mark the end of the string.$count$characters must be supplied worth of +space in$s$, but the number of characters read is at most$count$- 1. +The extra character space is used to hold the null character at the end of +the string. + + + +getc() Macro *crv-getc* +------------ +Synopsis~ + $#include <stdio.h>$ + $int getc(FILE *stream);$ + +Return~ +character read from stream +error or end-of-file:$EOF$ + +Description~ +This is just like$fgetc()$, except that it is permissible (and typical) for +it to be implemented as a macro that evaluates the stream argument more +than once.$getc()$is often highly optimized, so it is usually the best +function to use to read a single character. + + + +getchar() Function *crv-getchar* +------------------ +Synopsis~ + $#include <stdio.h>$ + $int getchar(void);$ + +Return~ +character read from stream +error or end-of-file:$EOF$ + +Description~ +This function is equivalent to$getc()$with$stdin$as the value of the stream +argument. + + + +gets() Function *crv-gets* +--------------- +Synopsis~ + $#include <stdio.h>$ + $char *gets(char *s);$ + +Return~ +If$gets()$encounters a read error or end-of-file, it returns a null pointer; +otherwise it returns$s$. + +Description~ +This function reads characters from the stream$stdin$up to the next newline +character, and stores them in the string$s$. The newline character is +discarded (note that this differs from the behavior of$fgets()$, which copies +the newline character into the string). + + + +ungetc() Function *crv-ungetc* +----------------- +Synopsis~ + $#include <stdio.h>$ + $int ungetc(int c, FILE *stream);$ + +Return~ +$c$pushed back after conversion or$EOF$if the operation fails + +Description~ +This function pushes back the character$c$onto the input stream$stream$. So +the next input from$stream$will read$c$before anything else. + +If$c$is$EOF$,$ungetc()$does nothing and just returns$EOF$. This allows to +call$ungetc()$with the return value of$getc()$without needing to check for an +error from$getc()$. + +The character that is pushed back doesn't have to be the same as the last +character that was actually read from the stream. In fact, it isn't necessary +to actually read any characters from the stream before unreading them with +$ungetc()$. But that is a strange way to write a program; usually$ungetc()$ +is used only to unread a character that was just read from the same stream. + +Pushing back characters doesn't alter the file; only the internal buffering +for the stream is affected. If a file positioning function (such as$fseek()$, +$fseeko()$ or$rewind()$) is called, any pending pushed-back characters are +discarded. + +Unreading a character on a stream that is at end of file clears the +end-of-file indicator for the stream, because it makes the character of +input available. After reading that character, trying to read again will +encounter end of file. + + + +fputc() Function *crv-fputc* +---------------- +Synopsis~ + $#include <stdio.h>$ + $int fputc(int c, FILE *stream);$ + +Return~ +$EOF$is returned if a write error occurs; otherwise the character$c$is +returned + +Description~ +This function converts the character$c$to type$unsigned char$, and writes it +to the stream$stream$. + + + +fputs() Function *crv-fputs* +---------------- +Synopsis~ + $#include <stdio.h>$ + $int fputs(const char *s, FILE *stream);$ + +Return~ +This function returns$EOF$if a write error occurs, and otherwise a +non-negative value. + +Description~ +This function writes the string$s$to the stream$stream$. The terminating +null character is not written. This function does not add a newline character, +either. It outputs only the characters in the string. + + + +putc() Macro *crv-putc* +------------ +Synopsis~ + $#include <stdio.h>$ + $int putc(int c, FILE *stream);$ + +Return~ +This function returns$EOF$if a write error occurs, and otherwise the +character written. + +Description~ +This is just like$fputc()$, except that most systems implement it as a +macro, making it faster. One consequence is that it may evaluate the stream +argument more than once, which is an exception to the general rule for +macros.$putc()$is usually the best function to use for writing a single +character. + + + +putchar() Function *crv-putchar* +------------------ +Synopsis~ + $#include <stdio.h>$ + $int putchar(int c);$ + +Return~ +This function returns$EOF$if a write error occurs, and otherwise the +character written. + +Description~ +This function is equivalent to$putc()$with$stdout$as the value of the stream +argument. + + + +puts() Function *crv-puts* +--------------- +Synopsis~ + $#include <stdio.h>$ + $int puts(const char *s);$ + +Return~ +This function returns$EOF$if a write error occurs, and otherwise a +non-negative value. + +Description~ +This function writes the string$s$to the stream$stdout$followed by a newline. +The terminating null character of the string is not written. (Note that +$fputs()$does not write a newline as this function does.) + +$puts()$is the most convenient function for printing simple messages. + + + +------------------------------------------------------------------------------ +II.19.8 Direct Input/Output *crv-libSIOHDIO* + +This section describes how to do input and output operations on blocks of +data. This functions can be used to read and write binary data, as well as to +read and write text in fixed-size blocks instead of by characters or lines. + +Binary files are typically used to read and write blocks of data in the same +format as is used to represent the data in a running program. In other words, +arbitrary blocks of memory--not just character or string objects--can be +written to a binary file, and meaningfully read in again by the same program. + +Storing data in binary form is often considerably more efficient than using +the formatted I/O functions. Also, for floating-point numbers, the binary form +avoids possible loss of precision in the conversion process. On the other +hand, binary files can't be examined or modified easily using many standard +file utilities (such as text editors), and are not portable between +different implementations of the language, or different kinds of computers. + + +fread() Function *crv-fread* +---------------- +Synopsis~ + $#include <stdio.h>$ + $size_t fread(void *data, size_t size, size_t count, FILE *stream);$ + +Return~ +It returns the number of objects actually read, which might be less than +$count$if a read error occurs or the end of the file is reached. This +function returns a value of zero (and doesn't read anything) if +either$size$or$count$is zero. +If$fread()$encounters end of file in the middle of an object, it returns +the number of complete objects read, and discards the partial object. +Therefore, the stream remains at the actual end of the file. + +Description~ +This function reads up to$count$objects of size$size$into the array$data$, +from the stream$stream$. + + +fwrite() Function *crv-fwrite* +----------------- +Synopsis~ + $#include <stdio.h>$ + $size_t fwrite(const void *data, size_t size, size_t count, FILE *stream);$ + +Return~ +The return value is normally$count$, if the call succeeds. +Any other value indicates some sort of error, such as running out of space. + +Description~ +This function writes up to count objects of size$size$from the array$data$, +to the stream$stream$. + + + + +------------------------------------------------------------------------------ +II.19.9 File Positioning *crv-libSIOHFPos* + +The file position of a stream describes where in the file the stream is +currently reading or writing. I/O on the stream advances the file position +through the file. + +Quicklink: + $fgetpos()$ Func |crv-fgetpos| + $fseek()$ Func |crv-fseek| + $fsetpos()$ Func |crv-fsetpos| + $ftell()$ Func |crv-ftell| + $rewind()$ Func |crv-rewind| + + + +fgetpos() Function *crv-fgetpos* +------------------ +Synopsis~ + $#include <stdio.h>$ + $int fgetpos(FILE *stream, fpos_t *position);$ + +Return~ +If successful,$fgetpos()$ returns zero; otherwise it returns a nonzero value +and stores an implementation-defined positive value in$errno$. + +Description~ +This function stores the value of the file position indicator for the stream +$stream$in the$fpos_t$object pointed to by$position$. + + + +fseek() Function *crv-fseek* +---------------- +Synopsis~ + $#include <stdio.h>$ + $int fseek(FILE *stream, long int offset, int whence);$ + +Return~ +0 if successful, +else failed + +Description~ +This function is used to change the file position of the stream$stream$. The +value of$whence$must be one of the constants$SEEK_SET$,$SEEK_CUR$, or +$SEEK_END$, to indicate whether the offset is relative to the beginning of the +file, the current file position, or the end of the file, respectively. + + + +fsetpos() Function *crv-fsetpos* +------------------ +Synopsis~ + $#include <stdio.h>$ + $int fsetpos(FILE *stream, const fpos_t *position);$ + +Return~ +If successful,$fsetpos()$clears the end-of-file indicator on the stream, +discards any characters that were "pushed back" by the use of$ungetc()$, and +returns a value of zero. +Otherwise, it returns a nonzero value and stores an implementation-defined +positive value in$errno$. + +Description~ +This function sets the file position indicator for the stream$stream$to the +position$position$, which must have been set by a previous call to$fgetpos()$ +on the same stream. + + + +ftell() Function *crv-ftell* +---------------- +Synopsis~ + $#include <stdio.h>$ + $long int ftell(FILE *stream);$ + +Return~ +This function can fail if the stream doesn't support file positioning, or if +the file position can't be represented in a$long int$, and possibly for other +reasons as well. If a failure occurs, a value of -1L is returned and an +implementation-defined positive value is stored in$errno$. + +Description~ +This function returns the current file position of the stream$stream$. + + + +rewind() Function *crv-rewind* +----------------- +Synopsis~ + $#include <stdio.h>$ + $void rewind(FILE *stream);$ + +Return~ +none + +Description~ +This function positions the stream$stream$at the beginning of the file. It is +equivalent to calling$fseek()$on the stream with an offset argument of 0L and a +whence argument of$SEEK_SET$, except that the return value is discarded and the +error indicator for the stream is reset. + + + + +------------------------------------------------------------------------------ +II.19.10 Error Handling *crv-libSIOHErr* + +Quicklink: + $clearerr()$ Func |crv-libclearerr| + $feof()$ Func |crv-libfeof| + $ferror()$ Func |crv-libferror| + $perror()$ Func |crv-libperror| + + + +clearerr() Function *crv-clearerr* +------------------- +Synopsis~ + $#include <stdio.h>$ + $void clearerr(FILE *stream);$ + +Return~ +none + +Description~ +This function clears the end-of-file and error indicators for the stream +$stream$. +The file positioning functions also clear the end-of-file indicator for the +stream. + + + +feof() Function *crv-feof* +--------------- +Synopsis~ + $#include <stdio.h>$ + $int feof(FILE *stream);$ + +Return~ +0: no EOF +else: EOF + +Description~ +This function returns nonzero if and only if the end-of-file indicator for the +stream$stream$ is set. + + + +ferror() Function *crv-ferror* +----------------- +Synopsis~ + $#include <stdio.h>$ + $int ferror(FILE *stream);$ + +Return~ +0: no error +else: error indicator is set + +Description~ +This function returns nonzero if and only if the error indicator for the +stream $stream$is set, indicating that an error has occurred on a previous +operation on the stream. + + + +perror() Function *crv-perror* +----------------- +Synopsis~ + $#include <stdio.h>$ + $void perror(const char *msg);$ + +Return~ +none + +Description~ +This function prints an error message to the stream$stderr$. The orientation +of$stderr$is not changed. + +If$perror()$is called with a message that is either a null pointer or an empty +string,$perror()$just prints the error message corresponding to$errno$, adding +a trailing newline. + +If it's called with a non-null message argument, then$perror()$prefixes its +output with this string. It adds a colon and a space character to separate the +message from the error string corresponding to$errno$. + + + + +============================================================================== +II.20 <stdlib.h> Utilities *crv-libStdlibH* + +This header file declares types, macros and functions of general utility. + + + +------------------------------------------------------------------------------ +II.20.1 Types *crv-libSLHType* + +Quicklink: + $dif_t$ Type |crv-libdif_t| + $ldif_t$ Type |crv-libldif_t| + $lldif_t$ Type |crv-liblldif_t| + $size_t$ Type |crv-libsize_t2| + $wchar_t$ Type |crv-libwchar_t2| + + + +dif_t Type *crv-dif_t* +---------- +This is a structure type used to hold the result returned by the$div()$ +function. It has the following members: + $int quot$: The quotient from the division. + $int rem$ : The remainder from the division. + + +ldif_t Type *crv-ldif_t* +----------- +This is a structure type used to hold the result returned by the$ldiv()$ +function. It has the following members: + $long int quot$: The quotient from the division. + $long int rem$ : The remainder from the division. + + +lldif_t Type *crv-lldif_t* +------------ +This is a structure type used to hold the result returned by the$ldiv()$ +function. It has the following members: + $long long int quot$: The quotient from the division. + $long long int rem$ : The remainder from the division. + + +size_t Type *crv-size_t2* +----------- +This is an unsigned integer type used to represent the sizes of objects. +Also declared in$<stddef.h>$, see |crv-libsize_t|. +Also declared in$<string.h>$, see |crv-libsize_t3|. +Also declared in$<time.h>$, see |crv-libsize_t4|. +Also declared in$<stdio.h>$, see |crv-libsize_t5|. +Also declared in$<wchar.h>$, see |crv-libsize_t6|. + + +wchar_t Type *crv-wchar_t2* +------------ +This data type is used as the base type for wide character strings. +It's range of values can represent distinct codes for all members of the +largest extended character set specified among the supported locales. +Also declared in$<stddef.h>$, see |crv-libwchar_t|. +Also declared in$<wchar.h>$, see |crv-libwchar_t3|. + + + + +------------------------------------------------------------------------------ +II.20.2 Macros *crv-libSLHMac* + +Quicklink: + $EXIT_SUCCESS$ Macro |crv-libEXIT_SUCCESS| + $EXIT_FAILURE$ Macro |crv-libEXIT_FAILURE| + $MB_CUR_MAX$ Macro |crv-libMB_CUR_MAX| + $NULL$ Macro |crv-libNULL2| + $RAND_MAX$ Macro |crv-libRAND_MAX| + + + +RAND_MAX Macro *crv-RAND_MAX* +-------------- +The value of this macro is an integer constant representing the largest value +the rand function can return. Its value is implementation-defined, but at +least 32767. + + + +EXIT_SUCCESS Macro *crv-EXIT_SUCCESS* +------------------ +This macro can be used with the$exit()$function to indicate successful program +completion. + + + +EXIT_FAILURE Macro *crv-EXIT_FAILURE* +------------------ +This macro can be used with the$exit()$function to indicate unsuccessful +program completion in a general sense. + + + +NULL Macro *crv-NULL2* +---------- +Expands to an implementation-defined null pointer constant. +Also defined in$<stddef.h>$, see |crv-NULL|. +Also defined in$<string.h>$, see |crv-NULL3|. +Also defined in$<time.h>$, see |crv-NULL4|. +Also defined in$<stdio.h>$, see |crv-NULL5|. +Also defined in$<wchar.h>$, see |crv-NULL6|. + + + +MB_CUR_MAX Macro *crv-MB_CUR_MAX* +---------------- +This macro expands into a positive integer expression that is the maximum +number of bytes in a multibyte character in the current locale. The value +is never greater than$MB_LEN_MAX$. + + + + +------------------------------------------------------------------------------ +II.20.3 Numeric Conversion *crv-libSLHnum* + +Quicklink: + $atof()$ Func |crv-atof| + $atoi()$ Func |crv-atoi| + $atol()$ Func |crv-atol| + $atoll()$ Func |crv-atoll| + $strtod()$ Func |crv-strtod| + $strtof()$ Func |crv-strtof| + $strtol()$ Func |crv-strtol| + $strtold()$ Func |crv-strtold| + $strtoll()$ Func |crv-strtoll| + $stroul()$ Func |crv-stroul| + $strtoull()$Func |crv-strtoull| + + + +atof() Function *crv-atof* +--------------- +Synopsis~ + $#include <stdlib.h>$ + $double atof(const char *string);$ + +Return~ +result of conversion + +Description~ +This function converts the initial portion of the string$string$to a$double$ +representation. This function is similar to the$strtod()$function, except that +it need not detect overflow and underflow errors. +The atof function is provided mostly for compatibility with existing code; +using$strtod()$is more robust. + + + +atol() Function *crv-atol* +--------------- +Synopsis~ + $#include <stdlib.h>$ + $long int atol(const char *string);$ + +Return~ +result of conversion + +Description~ +This function converts the string$string$to an$long int$value. +This function is similar to the$strtol()$function with a base argument of 10, +except that it need not detect overflow errors. The$atol()$function is +provided mostly for compatibility with existing code; using$strtol()$is more +robust. + + + +atoi() Function *crv-atoi* +--------------- +Synopsis~ + $#include <stdlib.h>$ + $int atoi(const char *string);$ + +Return~ +result of conversion + +Description~ +This function converts the string$string$to an$int$value. +The$atoi()$function is considered obsolete; use$strtol()$instead. + + + +atoll() Function *crv-atoll* +---------------- +Synopsis~ + $#include <stdlib.h>$ + $long long int atoll(const char *string);$ + +Return~ +result of conversion + +Description~ +This function converts the string$string$to an$long long int$value. +The$atoll()$function was introduced in ISO C99. It is obsolete (despite having +just been added); use$strtoll()$instead. + + + + +strtol() Function *crv-strtol* +----------------- +Synopsis~ + $#include <stdlib.h>$ + $long int strtol(const char *restrict string, char **restrict tailptr,$ + $int base);$ + +Return~ +no error: value of conversion +no conversion: 0 is returned +out of range: result is$LONG_MAX$or$LONG_MIN$(according to sign), + $ errno$is set to$ERANGE$ + +Description~ +The$strtol()$("string-to-long") function converts the initial part of string to +a signed integer, which is returned as a value of type$long int$. + +This function attempts to decompose$string$as follows: + + - A (possibly empty) sequence of whitespace characters. Which characters are + whitespace is determined by the$isspace()$function. These are discarded. + - An optional plus or minus sign (+ or -). + - A nonempty sequence of digits in the radix specified by$base$. + If$base$is zero, decimal radix is assumed unless the series of digits + begins with 0 (specifying octal radix), or 0x or 0X (specifying + hexadecimal radix); in other words, the same syntax used for integer + constants in C. + Otherwise$base$must have a value between 2 and 36. If$base$is 16, the + digits may optionally be preceded by 0x or 0X. If$base$has no legal value + the value returned is 0l and the global variable$errno$is set to$EINVAL$. + - Any remaining characters in the string. If$tailptr$is not a null pointer, + $strtol()$stores a pointer to this tail in$*tailptr$. + +If the string is empty, contains only whitespace, or does not contain an +initial substring that has the expected syntax for an integer in the specified +$base$, no conversion is performed. In this case,$strtol()$returns a value of +zero and the value stored in$*tailptr$is the value of$string$. + +In a locale other than the standard "C" locale, this function may recognize +additional implementation-dependent syntax. + +Checking for errors by examining the return value of$strtol()$should not be +done, because the string might be a valid representation of 0l,$LONG_MAX$, +or$LONG_MIN$. Instead, check whether$tailptr$points to what is expected after +the number (e.g. '\0' if the string should end after the number). $errno$needs +also to be cleared before the call and checked afterwards, in case there was +overflow. + + + +strtoll() Function *crv-strtoll* +------------------ +Synopsis~ + $#include <stdlib.h>$ + $long long int strtoll(const char *restrict string, char **restrict tailptr,$ + $int base);$ + +Return~ +no error: value of conversion +no conversion: 0 is returned +out of range: result is$LONG_LONG_MAX$or$LONG_LONG_MIN$(according to sign), + $errno$is set to$ERANGE$ + +Description~ +This function is like$strtol()$except that it returns a$long long int$value, +and accepts numbers with a correspondingly larger range. + + + +stroul() Function *crv-stroul* +----------------- +Synopsis~ + $#include <stdlib.h>$ + $unsigned long int strtoul(const char *retrict string,$ + $char **restrict tailptr, int base);$ + +Return~ +no error: value of conversion +no conversion: 0 is returned +out of range: result is$ULONG_MAX$,$errno$is set to$ERANGE$ + +Description~ +The$strtoul()$("string-to-unsigned-long") function is like$strtol()$except it +converts to an$unsigned long int$value. The syntax is the same as described +for$strtol$. + + + +strtoull() Function *crv-strtoull* +------------------- +Synopsis~ + $#include <stdlib.h>$ + $unsigned long long int strtoull(const char *restrict string,$ + $char **restrict tailptr, int base);$ + +Return~ +no error: value of conversion +no conversion: 0 is returned +out of range: result is$ULONG_LONG_MAX$,$errno$is set to$ERANGE$ + +Description~ +This function is like$strtol()$except that it returns an +$unsigned long long int$value, and accepts numbers with a correspondingly +larger range. + + + + +strtod() Function *crv-strtod* +----------------- +Synopsis~ + $#include <stdlib.h>$ + $double strtod(const char *restrict string, char **restrict tailptr);$ + +Return~ +no error: value of conversion +no conversion: 0 is returned +out of range: result is $-HUGE_VAL$or$+HUGH_VAL$(according to sign), + $errno$is set to$ERANGE$ + +Description~ +The$strtod()$("string-to-double") function converts the initial part of string +to a floating-point number, which is returned as a value of type$double$. + +This function attempts to decompose$string$as follows: + + - A (possibly empty) sequence of whitespace characters. Which characters are + whitespace is determined by the$isspace()$function. These are discarded. + - An optional plus or minus sign (+ or -). + - A floating point number in decimal or hexadecimal format. The decimal + format is: + o A nonempty sequence of digits optionally containing a decimal-point + character - normally, but it depends on the locale. + o An optional exponent part, consisting of a character e or E, an + optional sign, and a sequence of digits. + + The hexadecimal format is as follows: + o A 0x or 0X followed by a nonempty sequence of hexadecimal digits + optionally containing a decimal-point character - normally, but it + depends on the locale. + o An optional binary-exponent part, consisting of a character p or P, + an optional sign, and a sequence of digits. + + - Any remaining characters in the string. If$tailptr$is not a null pointer, + a pointer to this tail of the string is stored in$*tailptr$. + +If the string is empty, contains only whitespace, or does not contain an +initial substring that has the expected syntax for a floating-point number, no +conversion is performed. In this case,$strtod()$returns a value of zero +and the value returned in$*tailptr$is the value of$string$. + +In a locale other than the standard "C", this function may recognize +additional locale-dependent syntax. + +If the string has valid syntax for a floating-point number but the value +is outside the range of a$double$,$strtod()$will signal overflow or +underflow as described in II.12.1 Error Conditions (|crv-libMHErr|). + +$strtod()$recognizes four special input strings. The strings "inf" +and "infinity" are converted to ∞, or to the largest representable +value if the floating-point format doesn't support infinities. You can +prepend a "+" or "-" to specify the sign. Case is ignored when scanning +these strings. + +The strings "nan" and "nan(chars...)" are converted to NaN. Again, case is +ignored. If chars... are provided, they are used in some unspecified fashion +to select a particular representation of NaN (there can be several). + +Since zero is a valid result as well as the value returned on error, you +should check for errors in the same way as for$strtol()$, by examining +$errno$and$tailptr$. + + + +strtof() Function *crv-strtof* +----------------- +Synopsis~ + $#include <stdlib.h>$ + $float strtof(const char *string, char **tailptr);$ + +Return~ +no error: value of conversion +no conversion: 0 is returned +out of range: result is $-HUGE_VALF$or$+HUGH_VALF$(according to sign), + $errno$is set to$ERANGE$ + +Description~ +This function is analogous to$strtod()$, but return$float$values respectively; +it reports errors in the same way. + + + +strtold() Function *crv-strtold* +------------------ +Synopsis~ + $#include <stdlib.h>$ + $long double strtold(const char *string, char **tailptr);$ + +Return~ +no error: value of conversion +no conversion: 0 is returned +out of range: result is $-HUGE_VALL$or$+HUGH_VALL$(according to sign), + $errno$is set to$ERANGE$ + +Description~ +This function is analogous to$strtod()$, but return$long double$values +respectively; it reports errors in the same way. + + + + +------------------------------------------------------------------------------ +II.20.4 Pseudo-Random *crv-libSLHrand* + +This section describes the random number functions. + +Quicklink: + $rand()$ Func |crv-rand| + $srand()$ Func |crv-srand| + + + +rand() Function *crv-rand* +--------------- +Synopsis~ + $#include <stdlib.h>$ + $int rand(void);$ + +Return~ +pseudo-random number + +Description~ +This function returns the next pseudo-random number in the series. The value +ranges from 0 to$RAND_MAX$. + + + +srand() Function *crv-srand* +---------------- +Synopsis~ + $#include <stdlib.h>$ + $void srand(unsigned int seed);$ + +Return~ +none + +Description~ +This function establishes$seed$as the seed for a new series of pseudo-random +numbers. +If$rand()$is called before a seed has been established with$srand()$, it uses +the value 1 as a default seed. + +To produce a different pseudo-random series each time program starts, do +$srand (time (0))$. + + + + +------------------------------------------------------------------------------ +II.20.5 Memory Management *crv-libSLHmem* + +Quicklink: + $calloc()$ Func |crv-calloc| + $free()$ Func |crv-free| + $malloc()$ Func |crv-malloc| + $realloc()$Func |crv-realloc| + + +calloc() Function *crv-calloc* +----------------- +Synopsis~ + $#include <stdlib.h>$ + $void *calloc(size_t count, size_t eltsize);$ + +Return~ +pointer to allocated space or null pointer, if failed + +Description~ +This function allocates a block long enough to contain a vector of$count$ +elements, each of size$eltsize$. Its contents are cleared to zero before +$calloc()$returns. + + + +free() Function *crv-free* +---------------- +Synopsis~ + $#include <stdlib.h>$ + $void free(void *ptr);$ + +Return~ +none + +Description~ +This function deallocates the block of memory pointed at by$ptr$that was +allocated by$calloc()$,$malloc()$or$realloc()$. +It is allowed for$ptr$to be a null pointer. + + + +malloc() Function *crv-malloc* +----------------- +Synopsis~ + $#include <stdlib.h>$ + $void *malloc(size_t size);$ + +Return~ +pointer to allocated space or null pointer, if failed + +Description~ +This function returns a pointer to a newly allocated block$size$bytes long. +The contents of the block is undefined. + + + +realloc() Function *crv-realloc* +------------------ +Synopsis~ + $#include <stdlib.h>$ + $void *realloc(void *ptr, size_t newsize);$ + +Return~ +pointer to new block or null pointer, if failed + +Description~ +This function changes the size of the block whose address is$ptr$to be +$newsize$. +Since the space after the end of the block may be in use,$realloc()$may find +it necessary to copy the block to a new address where more free space is +available. If the block needs to be moved,$realloc()$copies the old contents. + +If a null pointer is passed for$ptr$,$realloc()$behaves just like +$malloc(newsize)$. +If memory for the new block cannot be allocated the old block is not +deallocated and its value is unchanged. + + + + +------------------------------------------------------------------------------ +II.20.6 Communication *crv-libSLHcom* + +Quicklink: + $_Exit()$ Func |crv-_Exit| + $abort()$ Func |crv-abort| + $atexit()$ Func |crv-atexit| + $exit()$ Func |crv-exit| + $getenv()$ Func |crv-getenv| + $system()$ Func |crv-system| + + + +abort() Function *crv-abort* +---------------- +Synopsis~ + $#include <stdlib.h>$ + $void abort(void);$ + +Return~ +this function does not return to its caller + +Description~ +This function causes abnormal program termination. This does not execute +cleanup functions registered with$atexit()$. This function actually terminates +the process by raising a SIGABRT signal. + + + +atexit() Function *crv-atexit* +----------------- +Synopsis~ + $#include <stdlib.h>$ + $int atexit(void (*function) (void));$ + +Return~ +0: successful +else: failed to register function + +Description~ +This function registers the function$function$to be called at normal program +termination. The$function$is called with no arguments. + + + +exit() Function *crv-exit* +--------------- +Synopsis~ + $#include <stdlib.h>$ + $void exit(int status);$ + +Return~ +this function does not return to its caller + +Description~ +This function tells the system that the program is done, which causes it to +terminate the process. The value of$status$is returned to the environment. + +Normal termination causes the following actions: + - Functions that were registered with the$atexit()$function are called in + the reverse order of their registration. This mechanism allows the + application to specify its own "cleanup" actions to be performed at + program termination. + - All open streams are closed, writing out any buffered output data. + In addition, temporary files opened with the$tmpfile()$function are + removed. + - Control is returned to the host environment. If$status$is zero or + $EXIT_SUCCESS$, then this signifies a successful termination. If$status$ + is$EXIT_FAILURE$, then this signifies an unsuccessful termination. + Other values are implementation-defined. + + + +_Exit() Function *crv-_Exit* +---------------- +Synopsis~ + $#include <stdlib.h>$ + $void _Exit(int status);$ + +Return~ +this function does not return to its caller + +Description~ +This function is the primitive for causing a process to terminate with status +$status$. Calling this function does not execute cleanup functions registered +with$atexit()$. + +Termination causes the following actions: + - All open streams are closed, writing out any buffered output data. + In addition, temporary files opened with the$tmpfile()$function are + removed. + - Control is returned to the host environment. If$status$is zero or + $EXIT_SUCCESS$, then this signifies a successful termination. If$status$ + is$EXIT_FAILURE$, then this signifies an unsuccessful termination. + Other values are implementation-defined. + + + +getenv() Function *crv-getenv* +------------------ +Synopsis~ + $#include <stdlib.h>$ + $char * getenv(const char *name);$ + +Return~ +null pointer: environment variable not found +else: pointer to string representing the value of the environment + variable +Description~ +This function returns a string that is the value of the environment variable +$name$. This string must not be modified. + + + +system() Function *crv-system* +----------------- +Synopsis~ + $#include <stdlib.h>$ + $int system(const char *command);$ + +Return~ +If the$command$argument is a null pointer, a return value of zero indicates +that no command processor is available. +If the$command$argument is not a null pointer and the$system()$function does +return, it returns an implementation-defined value. + +Description~ +This function executes$command$as a shell command (shell = command processor). +If$command$is a null pointer, the$system()$function determines whether the +host environment has a command processor. + + + + +------------------------------------------------------------------------------ +II.20.7 Searching and Sorting *crv-libSLHsearch* + +Quicklink: + $bsearch()$ Func |crv-bsearch| + $qsort()$ Func |crv-qsort| + + +bsearch() Function *crv-bsearch* +------------------ +Synopsis~ + $#include <stdlib.h>$ + $void *bsearch(const void *key, const void *array, size_t count,$ + $size_t size, int (* compare)(const void *, const void *));$ + +Return~ +The return value is a pointer to the matching array element, or a null pointer +if no match is found. If the array contains more than one element that +matches, the one that is returned is unspecified. + +Description~ +This function ("binary-search") searches the sorted array$array$for an object +that is equivalent to$key$. The array contains$count$elements, each of which +is of size$size$bytes. + +The$compare$function is used to perform the comparison. This function is +called with two pointer arguments and should return an integer less than, +equal to, or greater than zero corresponding to whether its first argument +is considered less than, equal to, or greater than its second argument. The +elements of the$array$must already be sorted in ascending order according to +this comparison function. + + + +qsort() Function *crv-qsort* +---------------- +Synopsis~ + $#include <stdlib.h>$ + $void qsort(void *array, size_t count, size_t size,$ + $int (* compare)(const void *, const void *));$ + +Return~ +none + +Description~ +This function sorts the array$array$. The array contains$count$elements, each +of which is of size$size$. + +The$compare$function is used to perform the comparison on the array elements. +This function is called with two pointer arguments and should return an +integer less than, equal to, or greater than zero corresponding to whether its +first argument is considered less than, equal to, or greater than its second +argument. + +If two objects compare as equal, their order after sorting is unpredictable. +That is to say, the sorting is not stable. This can make a difference when +the comparison considers only part of the elements. Two elements with the +same sort key may differ in other respects. + + + + +------------------------------------------------------------------------------ +II.20.8 Integer Arithmetic *crv-libSLHintarith* + +Quicklink: + $abs()$ Func |crv-abs| + $labs()$ Func |crv-labs| + $llabs()$ Func |crv-llabs| + $div()$ Func |crv-div| + $ldiv()$ Func |crv-ldiv| + $lldiv()$ Func |crv-lldiv| + + + +abs() Function *crv-abs* +-------------- +Synopsis~ + $#include <stdlib.h>$ + $int abs(int number);$ + +Return~ +absolute value + +Description~ +Evaluates the absolute value of$number$. + + + +labs() Function *crv-labs* +--------------- +Synopsis~ + $#include <stdlib.h>$ + $long int labs(long int number);$ + +Return~ +absolute value + +Description~ +Evaluates the absolute value of$number$. + + + +llabs() Function *crv-llabs* +---------------- +Synopsis~ + $#include <stdlib.h>$ + $long long int labs(long long int number);$ + +Return~ +absolute value + +Description~ +Evaluates the absolute value of$number$. + + + +div() Function *crv-div* +-------------- +Synopsis~ + $#include <stdlib.h>$ + $div_t div(int numerator, int denominator);$ + +Return~ +return the result in a structure of type$div_t$ +If the result cannot be represented (as in a division by zero), the +behavior is undefined. + +Description~ +This function computes the quotient and remainder from the division of +$numerator$by$denominator$. + + + +ldiv() Function *crv-ldiv* +--------------- +Synopsis~ + $#include <stdlib.h>$ + $ldiv_t ldiv(long int numerator, long int denominator);$ + +Return~ +return the result in a structure of type$ldiv_t$ +If the result cannot be represented (as in a division by zero), the +behavior is undefined. + +Description~ +This function computes the quotient and remainder from the division of +$numerator$by$denominator$. + + + +lldiv() Function *crv-lldiv* +---------------- +Synopsis~ + $#include <stdlib.h>$ + $lldiv_t lldiv(long long int numerator, long long int denominator);$ + +Return~ +return the result in a structure of type$lldiv_t$ +If the result cannot be represented (as in a division by zero), the +behavior is undefined. + +Description~ +This function computes the quotient and remainder from the division of +$numerator$by$denominator$. + + + + +------------------------------------------------------------------------------ +II.20.9 Multibyte/Wide Character *crv-libSLHmulchar* + +Quicklink: + $mblen()$ Func |crv-mblen| + $mbtowc()$ Func |crv-mbtowc| + $wctomb()$ Func |crv-wctomb| + + + +mblen() Function *crv-mblen* +---------------- +Synopsis~ + $#include <stdlib.h>$ + $int mblen(const char *string, size_t size);$ + +Return~ +see description + +Description~ +The$mblen()$function with a non-null string argument returns the number of +bytes that make up the multibyte character beginning at$string$, never +examining more than$size$bytes. + +The return value of$mblen()$distinguishes three possibilities: the first$size$ +bytes at$string$start with valid multibyte characters, they start with an +invalid byte sequence or just part of a character, or$string$points to an +empty string (a null character). + +For a valid multibyte character,$mblen()$returns the number of bytes in that +character (always at least 1 and never more than$size$). For an invalid byte +sequence,$mblen()$returns -1. For an empty string, it returns 0. + +If the multibyte character code uses shift characters, then$mblen()$maintains +and updates a shift state as it scans. If$mblen()$is called with a null +pointer for$string$, that initializes the shift state to its standard initial +value. It also returns a nonzero value if the multibyte character code in use +actually has a shift state. + + + +mbtowc() Function *crv-mbtowc* +----------------- +Synopsis~ + $#include <stdlib.h>$ + $int mbtowc(wchar_t *restrict result, const char *restrict string,$ + $size_t size);$ + +Return~ +see description + +Description~ +The$mbtowc()$("multibyte to wide character") function when called with +non-null$string$converts the first multibyte character beginning at$string$to +its corresponding wide character code. It stores the result in$*result$. +$mbtowc()$never examines more than$size$bytes. + +$mbtowc()$with non-null$string$distinguishes three possibilities: the first +size bytes at$string$start with valid multibyte characters, they start with +an invalid byte sequence or just part of a character, or string points to an +empty string (a null character). + +For a valid multibyte character,$mbtowc()$converts it to a wide character and +stores that in$*result$, and returns the number of bytes in that character +(always at least 1 and never more than$size$). + +For an invalid byte sequence,$mbtowc()$returns -1. For an empty string, it +returns 0, also storing '\0' in$*result$. + +If the multibyte character code uses shift characters, then$mbtowc()$ +maintains and updates a shift state as it scans. If$mbtowc()$is called with a +null pointer for$string$, that initializes the shift state to its standard +initial value. It also returns nonzero if the multibyte character code in use +actually has a shift state. + + + +wctomb() Function *crv-wctomb* +----------------- +Synopsis~ + $#include <stdlib.h>$ + $int wctomb(char *string, wchar_t wchar);$ + +Return~ +see description + +Description~ +The$wctomb()$("wide character to multibyte") function converts the wide +character code$wchar$to its corresponding multibyte character sequence, and +stores the result in bytes starting at$string$. At most$MB_CUR_MAX$characters +are stored. + +$wctomb()$with non-null string distinguishes three possibilities for$wchar$: a +valid wide character code (one that can be translated to a multibyte +character), an invalid code, and L'\0'. + +Given a valid code,$wctomb()$converts it to a multibyte character, storing the +bytes starting at$string$. Then it returns the number of bytes in that +character (always at least 1 and never more than$MB_CUR_MAX$). + +If$wchar$is an invalid wide character code,$wctomb()$returns -1. If$wchar$is +L'\0', it returns 0, also storing '\0' in$*string$. + +If the multibyte character code uses shift characters, then$wctomb()$maintains +and updates a shift state as it scans. If$wctomb()$is called with a null +pointer for$string$, that initializes the shift state to its standard initial +value. It also returns nonzero if the multibyte character code in use +actually has a shift state. + + + + +------------------------------------------------------------------------------ +II.20.10 Multibyte/Wide String *crv-libSLHmulstrng* + +Quicklink: +$mbstowcs()$ Func |crv-mbstowcs| +$wcstombs()$ Func |crv-wcstombs| + + + +mbstowcs() Function *crv-mbstowcs* +------------------- +Synopsis~ + $#include <stdlib.h>$ + $size_t mbstowcs(wchar_t *wstring, const char *string, size_t size);$ + +Return~ +see description + +Description~ +The$mbstowcs()$("multibyte string to wide character string") function converts +the null-terminated string of multibyte characters$string$to an array of wide +character codes, storing not more than$size$wide characters into the array +beginning at$wstring$. The terminating null character counts towards the size, +so if$size$is less than the actual number of wide characters resulting from +$string$, no terminating null character is stored. + +The conversion of characters from$string$begins in the initial shift state. + +If an invalid multibyte character sequence is found, the$mbstowcs()$function +returns a value of -1. Otherwise, it returns the number of wide characters +stored in the array$wstring$. This number does not include the terminating +null character, which is present if the number is less than$size$. + + + +wcstombs() Function *crv-wcstombs* +------------------- +Synopsis~ + $#include <stdlib.h>$ + $size_t wcstombs(char *string, const wchar_t *wstring, size_t size);$ + +Return~ +see description + +Description~ +The$wcstombs()$("wide character string to multibyte string") function converts +the null-terminated wide character array$wstring$into a string containing +multibyte characters, storing not more than$size$bytes starting at$string$, +followed by a terminating null character if there is room. + +The conversion of characters begins in the initial shift state. + +The terminating null character counts towards the size, so if$size$is less +than or equal to the number of bytes needed in$wstring$, no terminating null +character is stored. + +If a code that does not correspond to a valid multibyte character is found, +the$wcstombs()$function returns a value of -1. Otherwise, the return value is +the number of bytes stored in the array$string$. This number does not include +the terminating null character, which is present if the number is less than +$size$. + + + +============================================================================== +II.21 <string.h> String *crv-libStringH* + + + +------------------------------------------------------------------------------ +II.21.1 Types *crv-libSRHType* + +size_t Type *crv-size_t3* +----------- +This is an unsigned integer type used to represent the sizes of objects. +Also declared in$<stddef.h>$, see |crv-size_t|. +Also declared in$<stdlib.h>$, see |crv-size_t2|. +Also declared in$<time.h>$, see |crv-size_t4|. +Also declared in$<stdio.h>$, see |crv-size_t5|. +Also declared in$<wchar.h>$, see |crv-size_t6|. + + + + +------------------------------------------------------------------------------ +II.21.2 Macros *crv-libSRHMac* + +NULL Macro *crv-NULL3* +---------- +Expands to an implementation-defined null pointer constant. +Also defined in$<stddef.h>$, see |crv-NULL|. +Also defined in$<stdlib.h>$, see |crv-NULL2|. +Also defined in$<time.h>$, see |crv-NULL4|. +Also defined in$<stdio.h>$, see |crv-NULL5|. +Also defined in$<wchar.h>$, see |crv-NULL6|. + + + + + +------------------------------------------------------------------------------ +II.21.3 Copying *crv-libSRHCopy* + +The functions described in this section can be used to copy the contents of +strings and arrays. + +Quicklink: + $memcpy()$ Func |crv-memcpy| + $memmove()$ Func |crv-memmove| + $strcpy()$ Func |crv-strcpy| + $strncpy()$ Func |crv-strncpy| + + + +memcpy() Function *crv-memcpy* +----------------- +Synopsis~ + $#include <string.h>$ + $void *memcpy(void *restrict to, const void *restrict from, size_t size);$ + +Return~ +value of$to$ + +Description~ +This function copies$size$bytes from the object beginning at$from$into the +object beginning at$to$. The behavior of this function is undefined if the two +arrays$to$and$from$overlap; $memmove()$can be used instead if overlapping is +possible. + + + +memmove() Function *crv-memmove* +------------------ +Synopsis~ + $#include <string.h>$ + $void *memmove(void *to, const void *from, size_t size);$ + +Return~ +value of$to$ + +Description~ +This function copies the$size$bytes at$from$into the$size$bytes at$to$, even +if those two blocks of space overlap. In the case of overlap,$memmove()$is +careful to copy the original values of the bytes in the block at$from$, +including those bytes which also belong to the block at$to$. + + + +strcpy() Function *crv-strcpy* +----------------- +Synopsis~ + $#include <string.h>$ + $char *strcpy(char *restrict to, const char *restrict from);$ + +Return~ +value of$to$ + +Description~ +This copies characters from the string$from$(up to and including the +terminating null character) into the string$to$. Like$memcpy()$, this function +has undefined results if the strings overlap. + + + +strncpy() Function *crv-strncpy* +------------------ +Synopsis~ + $#include <string.h>$ + $char *strncpy(char *restrict to, const char *restrict from, size_t size);$ + +Return~ +value of$to$ + +Description~ +This function is similar to$strcpy()$but always copies exactly$size$characters +into$to$. + +If the length of$from$is more than$size$, then$strncpy()$copies just the first +size characters. In this case there is no null terminator written into$to$. + +If the length of$from$is less than$size$, then$strncpy()$copies all of$from$, +followed by enough null characters to add up to$size$characters in all. + +The behavior of$strncpy()$is undefined if the strings overlap. + +NOTE: Using$strncpy()$as opposed to$strcpy()$is a way to avoid bugs relating +to writing past the end of the allocated space for$to$. However, it can also +make your program much slower in one common case: copying a string which is +probably small into a potentially large buffer. In this case, size may be +large, and when it is,$strncpy()$ will waste a considerable amount of time +copying null characters. + + + + +------------------------------------------------------------------------------ +II.21.4 Concatenation *crv-libSRHConcat* + +Quicklink: + $strcat()$ Func |crv-strcat| + $strncat()$ Func |crv-strncat| + + +strcat() Function *crv-strcat* +----------------- +Synopsis~ + $#include <string.h>$ + $char *strcat(char *restrict to, const char *restrict from);$ + +Return~ +value of$to$ + +Description~ +This function is similar to$strcpy()$, except that the characters from$from$ +are concatenated or appended to the end of$to$, instead of overwriting it. +That is, the first character from$from$overwrites the null character marking +the end of$to$. +This function has undefined results if the strings overlap. + + + +strncat() Function *crv-strncat* +------------------ +Synopsis~ + $#include <string.h>$ + $char *strncat(char *restrict to, const char *restrict from, size_t size);$ + +Return~ +value of$to$ + +Description~ +This function is like$strcat()$except that not more than$size$characters from +$from$are appended to the end of$to$. A single null character is also always +appended to$to$, so the total allocated size of$to$must be at least +$size + 1$bytes longer than its initial length. +The behavior of this function is undefined if the strings overlap. + + + + +------------------------------------------------------------------------------ +II.21.5 Comparison *crv-libSRHCmp* + +Quicklink: + $memcmp()$ Func |crv-memcmp| + $strcmp()$ Func |crv-strcmp| + $strcoll()$ Func |crv-strcoll| + $strncmp()$ Func |crv-strncmp| + $strxfrm()$ Func |crv-strxfrm| + + + +memcmp() Function *crv-memcmp* +----------------- +Synopsis~ + $#include <string.h>$ + $int memcmp(const void *a1, const void *a2, size_t size);$ + +Return~ +The value returned is greater than, equal to, or less than zero, accordingly +as the object pointed to by$a1$is greater than, equal to, or less than the +object pointed to by$a2$. + +Description~ +This function compares the$size$bytes of memory beginning at$a1$against the +$size$bytes of memory beginning at$a2$. + + + +strcmp() Function *crv-strcmp* +----------------- +Synopsis~ + $#include <string.h>$ + $int strcmp(const char *s1, const char *s2);$ + +Return~ +The value returned is greater than, equal to, or less than zero, accordingly +as the string pointed to by$s1$is greater than, equal to, or less than the +string pointed to by$s2$. + +Description~ +This function compares the string$s1$against$s2$. + + + +strcoll() Function *crv-strcoll* +------------------ +Synopsis~ + $#include <string.h>$ + $int strcoll(const char *s1, const char *s2);$ + +Return~ +The value returned is greater than, equal to, or less than zero, accordingly +as the string pointed to by$s1$is greater than, equal to, or less than the +string pointed to by$s2$. + + +Description~ +This function is similar to$strcmp()$but uses the collating sequence of the +current locale for collation (the$LC_COLLATE$locale). + + + +strncmp() Function *crv-strncmp* +------------------ +Synopsis~ + $#include <string.h>$ + $int strncmp(const char *s1, const char *s2, size_t size);$ + +Return~ +The value returned is greater than, equal to, or less than zero, accordingly +as the string pointed to by$s1$is greater than, equal to, or less than the +string pointed to by$s2$. + +Description~ +This function is the similar to$strcmp()$, except that no more than$size$wide +characters are compared. In other words, if the two strings are the same in +their first$size$wide characters, the return value is zero. + + + +strxfrm() Function *crv-strxfrm* +------------------ +Synopsis~ + $#include <string.h>$ + $size_t strxfrm(char *restrict to, const char *restrict from, size_t size);$ + +Return~ +The return value is the length of the entire transformed string. +This value is not affected by the value of$size$, but if it is greater or +equal than$size$, it means that the transformed string did not entirely fit +in the array$to$. In this case, only as much of the string as actually fits +was stored. + +Description~ +This function transforms the string$from$using the collation transformation +determined by the locale currently selected for collation, and stores the +transformed string in the array$to$. Up to$size$characters (including a +terminating null character) are stored. + +If$size$is zero, no characters are stored in$to$. In this case,$strxfrm()$ +simply returns the number of characters that would be the length of the +transformed string. +This is useful for determining what size the allocated array should be. +It does not matter what$to$is if$size$is zero;$to$may even be a null pointer. + +The transformed string may be longer than the original string, and it may +also be shorter. + +The behavior is undefined if the strings$to$and$from$overlap. + + + + +------------------------------------------------------------------------------ +II.21.6 Search *crv-libSRHSearch* + +This section describes library functions which perform various kinds of +searching operations on strings and arrays. + +Quicklink: + $memchr()$ Func |crv-memchr| + $strchr()$ Func |crv-strchr| + $strcspn()$ Func |crv-strcspn| + $strpbrk()$ Func |crv-strpbrk| + $strrchr()$ Func |crv-strrchr| + $strspn()$ Func |crv-strspn| + $strstr()$ Func |crv-strstr| + $strtok()$ Func |crv-strtok| + + + + +memchr() Function *crv-memchr* +----------------- +Synopsis~ + $#include <string.h>$ + $void *memchr(const void *block, int c, size_t size);$ + +Return~ +pointer to the located byte, or null pointer if no match was found + +Description~ +This function finds the first occurrence of the byte$c$(converted to an +$unsigned char$) in the initial$size$bytes of the object beginning at$block$. + + + +strchr() Function *crv-strchr* +----------------- +Synopsis~ + $#include <string.h>$ + $char *strchr(const char *string, int c);$ + +Return~ +pointer to the located byte, or null pointer if no match was found + +Description~ +This function finds the first occurrence of the character$c$(converted to a +$char$) in the null-terminated string beginning at$string$. + + + +strcspn() Function *crv-strcspn* +------------------ +Synopsis~ + $#include <string.h>$ + $size_t strcspn(const char *string, const char *stopset);$ + +Return~ +length of substring + +Description~ +The$strcspn()$("string complement span") function returns the length of the +initial substring of$string$that consists entirely of characters that are not +members of the set specified by the string$stopset$. +(In other words, it returns the offset of the first character in$string$that +is a member of the set$stopset$.) + + + +strpbrk() Function *crv-strpbrk* +------------------ +Synopsis~ + $#include <string.h>$ + $char *strpbrk(const char *string, const char *stopset);$ + +Return~ +returns a pointer to the character, or null pointer if no such character +is found + +Description~ +The$strpbrk()$("string pointer break") function is related to$strcspn()$, +except that it returns a pointer to the first character in$string$that is a +member of the set$stopset$instead of the length of the initial substring. + + + +strrchr() Function *crv-strrchr* +------------------ +Synopsis~ + $#include <string.h>$ + $char *strrchr(const char *string, int c);$ + +Return~ +pointer to the located byte, or null pointer if no match was found + +Description~ +The function$strrchr()$is like$strchr()$, except that it searches backwards +from the end of the string$string$(instead of forwards from the front). + + + +strspn() Function *crv-strspn* +----------------- +Synopsis~ + $#include <string.h>$ + $size_t strspn(const char *string, const char *skipset);$ + +Return~ +length of substring + +Description~ +The$strspn()$("string span") function returns the length of the initial +substring of$string$that consists entirely of characters that are members of +the set specified by the string$skipset$. The order of the characters in +$skipset$is not important. + + + +strstr() Function *crv-strstr* +----------------- +Synopsis~ + $#include <string.h>$ + $char *strstr(const char *haystack, const char *needle);$ + +Return~ +It returns a pointer into the string$haystack$that is the first character of +the substring, or a null pointer if no match was found. If$needle$is an empty +string, the function returns$haystack$. + +Description~ +This is like$strchr()$, except that it searches$haystack$for a substring +$needle$rather than just a single character. + + + +strtok() Function *crv-strtok* +----------------- +Synopsis~ + $#include <string.h>$ + $char *strtok(char *restrict newstring, const char *restrict delimiters);$ + +Return~ +see description + +Description~ +A string can be split into tokens by making a series of calls to the function +$strtok()$. + +The string to be split up is passed as the$newstring$argument on the first +call only. The$strtok()$function uses this to set up some internal state +information. Subsequent calls to get additional tokens from the same string +are indicated by passing a null pointer as the$newstring$argument. Calling +$strtok()$with another non-null$newstring$argument reinitializes the state +information. It is guaranteed that no other library function ever calls +$strtok()$behind your back (which would mess up this internal state +information). + +The$delimiters$argument is a string that specifies a set of delimiters that +may surround the token being extracted. All the initial characters that are +members of this set are discarded. The first character that is not a member +of this set of delimiters marks the beginning of the next token. The end of +the token is found by looking for the next character that is a member of the +$delimiter$set. This character in the original string$newstring$is +overwritten by a null character, and the pointer to the beginning of the token +in$newstring$ is returned. + +On the next call to$strtok()$, the searching begins at the next character +beyond the one that marked the end of the previous token. +Note that the set of delimiters$delimiters$do not have to be the same on every +call in a series of calls to$strtok()$. + +If the end of the string$newstring$is reached, or if the remainder of$string$ +consists only of delimiter characters,$strtok()$returns a null pointer. + +Note that "character" is here used in the sense of byte. In a string using a +multibyte character encoding (abstract) character consisting of more than one +byte are not treated as an entity. Each byte is treated separately. The +function is not locale-dependent. + + + + +------------------------------------------------------------------------------ +II.21.7 Miscellaneous *crv-libSRHMisc* + +Quicklink: + $memset()$ Func |crv-memset| + $strerror()$ Func |crv-strerror| + $strlen()$ Func |crv-strlen| + + + +memset() Function *crv-memset* +----------------- +Synopsis~ + $#include <string.h>$ + $void *memset(void *block, int c, size_t size);$ + +Return~ +value of$block$ + +Description~ +This function copies the value of$c$(converted to an$unsigned char$) into each +of the first$size$bytes of the object beginning at$block$. + + + +strerror() Function *crv-strerror* +------------------- +Synopsis~ + $#include <string.h>$ + $char *strerror(int errnum);$ + +Return~ +The return value is a pointer to error message, which string should not be +modified. Also, if subsequent calls to$strerror()$are done, the string might +be overwritten. But it's guaranteed that no library function ever calls +$strerror()$. + +Description~ +This function maps the error code specified by the$errnum$argument to a +descriptive error message string. +The value$errnum$normally comes from the variable$errno$. + + + +strlen() Function *crv-strlen* +----------------- +Synopsis~ + $#include <string.h>$ + $size_t strlen(const char *s);$ + +Return~ +length of string + +Description~ +The$strlen()$function returns the length of the null-terminated string$s$in bytes. + + + + +============================================================================== +II.22 <tgmath.h> Type-Generic *crv-libTgmathH* + +This header file includes$<math.h>$and$<complex.h>$and defines several +type-generic macros. + +A type-generic macro expands to a function according to the type of the +macro's parameter(s). +E.g. there is a type-generic macro$fabs(parameter)$.This macro expands to: + -$fabs()$ if$parameter$is of type$double$ + -$fabsf()$ if$parameter$is of type$float$ + -$fabsl()$ if$parameter$is of type$long double$ + -$cabs()$ if$parameter$is of type$double complex$ + -$cabsf()$ if$parameter$is of type$float complex$ + -$cabsl()$ if$parameter$is of type$long double complex$ + +For each function declared in$<math.h>$and$<complex.h>$which has no f ($float$) +or l ($long double$) suffix, and which has one or more parameters of type +$double$a type-generic macro is defined (except for$mdof()$). + +For each function declared in$<math.h>$which has no suffix and for which there +is a corresponding function in$<complex.h>$with prefix c, a type-generic macro +is defined for both functions that has the name of the function declared +in$<math.h>$. + +The type-generic macros determine the real type as follows: + - if any parameter is of type$long double$, the type determined is + $long double$ + - otherwise, if any parameter is of type$double$or is of integer type, the + determined type is$double$ + - otherwise, the type determined is$float$ + + + + +============================================================================== +II.23 <time.h> Date and Time *crv-libTimeH* + +This header defines macros and declares types and functions for manipulating +time. + + + +------------------------------------------------------------------------------ +II.23.1 Types *crv-libTHType* + +Quicklink: + $size_t$ Type |crv-size_t4| + $clock_t$ Type |crv-clock_t| + $time_t$ Type |crv-time_t| + $tm$ Type |crv-tm| + + + +size_t Type *crv-size_t4* +----------- +This is an unsigned integer type used to represent the sizes of objects. +Also declared in$<stddef.h>$, see |crv-size_t|. +Also declared in$<stdlib.h>$, see |crv-size_t2|. +Also declared in$<string.h>$, see |crv-size_t3|. +Also declared in$<stdio.h>$, see |crv-size_t5|. +Also declared in$<wchar.h>$, see |crv-size_t6|. + + + +clock_t Type *crv-clock_t* +------------ +This is the type of the value returned by the$clock()$function. Values of +type$clock_t$are numbers of clock ticks. + + + +time_t Type *crv-time_t* +----------- +This is the data type used to represent simple time. Sometimes, it also +represents an elapsed time. When interpreted as a calendar time value, it +represents the number of seconds elapsed since 00:00:00 on January 1, 1970, +Coordinated Universal Time. (This calendar time is sometimes referred to as +the epoch.). + +NOTE: A simple time has no concept of local time zone. Calendar Time T +is the same instant in time regardless of where on the globe the computer is. + + + +struct tm Type *crv-tm* +-------------- +This is the data type used to represent a broken-down time. The structure +contains at least the following members, which can appear in any order. + +$int tm_sec$ + This is the number of full seconds since the top of the minute (normally + in the range 0 through 59, but the actual upper limit is 60, to allow for + leap seconds if leap second support is available). + +$int tm_min$ + This is the number of full minutes since the top of the hour (in the range + 0 through 59). + +$int tm_hour$ + This is the number of full hours past midnight (in the range 0 through 23). + +$int tm_mday$ + This is the ordinal day of the month (in the range 1 through 31). + +$int tm_mon$ + This is the number of full calendar months since the beginning of the year + (in the range 0 through 11). + +$int tm_year$ + This is the number of full calendar years since 1900. + +$int tm_wday$ + This is the number of full days since Sunday (in the range 0 through 6). + +$int tm_yday$ + This is the number of full days since the beginning of the year (in the + range 0 through 365). + +$int tm_isdst$ + This is a flag that indicates whether Daylight Saving Time is (or was, or + will be) in effect at the time described. The value is positive if + Daylight Saving Time is in effect, zero if it is not, and negative if the + information is not available. + +Also declared in$<wchar.h>$, see |crv-tm2|. + + + + +------------------------------------------------------------------------------ +II.23.2 Macros *crv-libTHMac* + +Quicklink: +$CLOCKS_PER_SEC$ Macro |crv-CLOCKS_PER_SEC| +$NULL$ Macro |crv-NULL4| + + + +NULL Macro *crv-NULL4* +---------- +Expands to an implementation-defined null pointer constant. +Also defined in$<stddef.h>$, see |crv-NULL|. +Also defined in$<stdlib.h>$, see |crv-NULL2|. +Also defined in$<string.h>$, see |crv-NULL3|. +Also defined in$<stdio.h>$, see |crv-NULL5|. +Also defined in$<wchar.h>$, see |crv-NULL6|. + + + +CLOCKS_PER_SEC Macro *crv-CLOCKS_PER_SEC* +-------------------- +The value of this macro is the number of clock ticks per second measured by +the$clock()$function. + + + +------------------------------------------------------------------------------ +II.23.3 Time Manipulation *crv-libTHMani* + +Quicklink: + $clock()$ Func |crv-clock| + $difftime()$ Func |crv-difftime| + $mktime()$ Func |crv-mktime| + $time()$ Func |crv-time| + + + +clock() Function *crv-clock* +---------------- +Synopsis~ + $#include <time.h>$ + $clock_t clock(void);$ + +Return~ +CPU time ot (clock_t)(-1) if an error occurred + +Description~ +This function returns the calling process' current CPU time. If the CPU time +is not available or cannot be represented, clock returns the value +(clock_t)(-1). +Time in seconds can be determined by dividing the result of$clock()$by +$CLOCKS_PER_SECOND$. + + + +difftime() Function *crv-difftime* +------------------- +Synopsis~ + $#include <time.h>$ + $double difftime(time_t time1, time_t time0);$ + +Return~ +seconds elapsed + +Description~ +This function returns the number of seconds of elapsed time between calendar +time$time1$and calendar time$time0$, as a value of type$double$. The +difference ignores leap seconds unless leap second support is enabled. + + + +mktime() Function *crv-mktime* +----------------- +Synopsis~ + $#include <time.h>$ + $time_t mktime(struct tm *brokentime);$ + +Return~ +Simple time, or if the specified broken-down time cannot be represented as a +simple time,$mktime()$returns a value of (time_t)(-1) and does not modify the +contents of$brokentime$. + +Description~ +The$mktime()$function is used to convert a broken-down time structure to a +simple time representation. It also "normalizes" the contents of the +broken-down time structure, by filling in the day of week and day of year +based on the other date and time components. + +The$mktime()$function ignores the specified contents of the$tm_wday$and +$tm_yday$members of the broken-down time structure. It uses the values of the +other components to determine the calendar time; it's permissible for these +components to have unnormalized values outside their normal ranges. The last +thing that$mktime()$does is adjust the components of the brokentime structure +(including the$tm_wday$and$tm_yday$). + + + +time() Function *crv-time* +--------------- +Synopsis~ + $#include <time.h>$ + $time_t time(time_t *result);$ + +Return~ +current calenar time or if the current calendar time is not available, +the value (time_t)(-1) + +Description~ +The$time()$function returns the current calendar time as a value of type +$time_t$. If the argument$result$is not a null pointer, the calendar time +value is also stored in$*result$. + + + + +------------------------------------------------------------------------------ +II.23.4 Time Conversion *crv-libTHConv* + +Quicklink: + $asctime()$ Func |crv-asctime| + $ctime()$ Func |crv-ctime| + $gmtime()$ Func |crv-gmtime| + $localtime()$ Func |crv-localtime| + $strftime()$ Func |crv-strftime| + + + +asctime() Function *crv-asctime* +------------------ +Synopsis~ + $#include <time.h>$ + $char *asctime(const struct tm *brokentime);$ + +Return~ +The return value points to a statically allocated string, which might be +overwritten by subsequent calls to$asctime()$or$ctime$. But no other library +function overwrites the contents of this string. + +Description~ +This function converts the broken-down time value that$brokentime$points to +into a string in a standard format: + "Tue May 21 13:46:22 1991\n" + +The abbreviations for the days of week are: Sun, Mon, Tue, Wed, Thu, Fri, and +Sat. + +The abbreviations for the months are: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, +Sep, Oct, Nov, and Dec. + + + +ctime() Function *crv-ctime* +---------------- +Synopsis~ + $#include <time.h>$ + $char *ctime(const time_t *time);$ + +Return~ +The return value points to a statically allocated string, which might be +overwritten by subsequent calls to$asctime()$or$ctime$. But no other library +function overwrites the contents of this string. + +Description~ +The$ctime()$function is similar to$asctime()$, except that calendar time +is specified as a$time_t$simple time value rather than in broken-down local +time format. It is equivalent to: + $asctime (localtime (time))$ + + + +gmtime() Function *crv-gmtime* +----------------- +Synopsis~ + $#include <time.h>$ + $struct tm *gmtime(const time_t *time);$ + +Return~ +returns pointer to the broken-down time, or a null pointer if the specified +time cannot be converted to UTC + +Description~ +This function is similar to$localtime()$, except that the broken-down time is +expressed as Coordinated Universal Time (UTC) (formerly called Greenwich Mean +Time (GMT)) rather than relative to a local time zone. + + + +localtime() Function *crv-localtime* +-------------------- +Synopsis~ + $#include <time.h>$ + $struct tm *localtime (const time_t *time);$ + +Return~ +returns pointer to the broken-down time, or a null pointer if the specified +time cannot be converted to local time + +Description~ +The$localtime()$function converts the simple time pointed to by$time$to +broken-down time representation, expressed relative to the user's specified +time zone. + + + +strftime() Function *crv-strftime* +------------------- +Synopsis~ + $#include <time.h>$ + $size_t strftime(char *s, size_t size, const char *format,$ + $const struct tm *brokentime;$ + +Return~ +number of characters placed in$s$, not including the terminating null +character +if this number is greater than$size$, zero is returned + +Description~ +This function is similar to the$sprintf()$function, but the conversion +specifications that can appear in the format$format$are specialized for +printing components of the date and time$brokentime$according to the locale +currently specified for time conversion. + +Ordinary characters appearing in the format are copied to the output +string$s$; this can include multibyte character sequences. Conversion +specifiers are introduced by a$%$character, followed by an optional +modifier. The modifier extensions are: + + - E Use the locale's alternate representation for date and time. This + modifier applies to the$%c, %C, %x, %X, %y, %Y$format specifiers. + - O Use the locale's alternate numeric symbols for numbers. This modifier + applies only to numeric format specifiers. + + +If the format supports the modifier but no alternate representation is +available, it is ignored. + +The conversion specifier ends with a format specifier taken from the following +list. The whole % sequence is replaced in the output string as follows: + +$%a$ The abbreviated weekday name according to the current locale. +$%A$ The full weekday name according to the current locale. +$%b$ The abbreviated month name according to the current locale. +$%B$ The full month name according to the current locale. +$%c$ The preferred calendar time representation for the current locale. +$%C$ The century of the year. This is equivalent to the greatest integer + not greater than the year divided by 100. +$%d$ The day of the month as a decimal number (range 01 through 31). +$%D$ The date using the format$%m/%d/%y$. +$%e$ The day of the month like with %d, but padded with blank (range 1 + through 31). +$%F$ The date using the format$%Y-%m-%d$. +$%g$ The year corresponding to the ISO week number, but without the century + (range 00 through 99). This has the same format and value as$%y$, + except that if the ISO week number (see$%V$) belongs to the previous + or next year, that year is used instead. +$%G$ The year corresponding to the ISO week number. This has the same format + and value as$%Y$, except that if the ISO week number (see %V) belongs + to the previous or next year, that year is used instead. +$%h$ The abbreviated month name according to the current locale. The action + is the same as for$%b$. +$%H$ The hour as a decimal number, using a 24-hour clock (range 00 through + 23). +$%I$ The hour as a decimal number, using a 12-hour clock (range 01 through + 12). +$%j$ The day of the year as a decimal number (range 001 through 366). +$%k$ The hour as a decimal number, using a 24-hour clock like$%H$, but padded + with blank (range 0 through 23). +$%l$ The hour as a decimal number, using a 12-hour clock like$%I$, but padded + with blank (range 1 through 12). +$%m$ The month as a decimal number (range 01 through 12). +$%M$ The minute as a decimal number (range 00 through 59). +$%n$ A single \n (newline) character. +$%p$ Either AM or PM, according to the given time value; or the corresponding + strings for the current locale. Noon is treated as PM and midnight as AM. +$%r$ The complete calendar time using the AM/PM format of the current locale. +$%R$ The hour and minute in decimal numbers using the format$%H:%M$. +$%S$ The seconds as a decimal number (range 00 through 60). +$%t$ A single \t (tabulator) character. +$%T$ The time of day using decimal numbers using the format$%H:%M:%S$. +$%u$ The day of the week as a decimal number (range 1 through 7), Monday + being 1. +$%U$ The week number of the current year as a decimal number (range 00 through + 53), starting with the first Sunday as the first day of the first week. + Days preceding the first Sunday in the year are considered to be in week + 00. +$%V$ The ISO 8601:1988 week number as a decimal number (range 01 through 53). + ISO weeks start with Monday and end with Sunday. Week 01 of a year is the + first week which has the majority of its days in that year; this is + equivalent to the week containing the year's first Thursday, and it is + also equivalent to the week containing January 4. Week 01 of a year can + contain days from the previous year. The week before week 01 of a year + is the last week (52 or 53) of the previous year even if it contains days + from the new year. +$%w$ The day of the week as a decimal number (range 0 through 6), Sunday + being 0. +$%W$ The week number of the current year as a decimal number (range 00 through + 53), starting with the first Monday as the first day of the first week. + All days preceding the first Monday in the year are considered to be in + week 00. +$%x$ The preferred date representation for the current locale. +$%X$ The preferred time of day representation for the current locale. +$%y$ The year without a century as a decimal number (range 00 through 99). + This is equivalent to the year modulo 100. +$%Y$ The year as a decimal number, using the Gregorian calendar. Years before + the year 1 are numbered 0, -1, and so on. +$%z$ RFC 822/ISO 8601:1988 style numeric time zone (e.g., -0600 or +0100), or + nothing if no time zone is determinable. + A full RFC 822 timestamp is generated by the format + $"%a, %d %b %Y %H:%M:%S %z"$ (or the equivalent$"%a, %d %b %Y %T %z"$). +$%Z$ The time zone abbreviation (empty if the time zone can't be determined). +$%%$ A literal % character. + + +The$size$parameter can be used to specify the maximum number of characters to +be stored in the array$s$, including the terminating null character. If the +formatted time requires more than$size$characters,$strftime()$returns zero +and the contents of the array$s$are undefined. Otherwise the return value +indicates the number of characters placed in the array$s$, not including +the terminating null character. + +Warning: This convention for the return value which is prescribed in ISO C +can lead to problems in some situations. For certain format strings and +certain locales the output really can be the empty string and this cannot +be discovered by testing the return value only. E.g., in most locales the +AM/PM time format is not supported (most of the world uses the 24 hour +time representation). In such locales$"%p"$will return the empty string, +i.e., the return value is zero. To detect situations like this something +similar to the following code should be used: +> + buf[0] = '\1'; + len = strftime (buf, bufsize, format, tp); + if (len == 0 && buf[0] != '\0') + { + /* Something went wrong in the strftime call. */ + ... + } + + +If$s$is a null pointer,$strftime()$does not actually write anything, but +instead returns the number of characters it would have written. + + + + +============================================================================== +II.24 <wchar.h> Wide Utilities *crv-libWcharH* + + +------------------------------------------------------------------------------ +II.24.1 Types *crv-libWCHType* + +Quicklink: + $mbstate_t$ Type |crv-mbstate_t| + $tm$ Type |crv-tm2| + $size_t$ Type |crv-size_t6| + $wchar_t$ Type |crv-wchar_t3| + $wint_t$ Type |crv-wint_t2| + + + +mbstate_t Type *crv-mbstate_t* +-------------- +A variable of type$mbstate_t$can contain all the information about the shift +state needed from one call to a conversion function to another. + + +struct tm Type *crv-tm2* +-------------- +Also declared in$<time.h>$, for description see |crv-tm|. + + +size_t Type *crv-size_t6* +----------- +This is an unsigned integer type used to represent the sizes of objects. +Also declared in$<stddef.h>$, see |crv-size_t|. +Also declared in$<stdlib.h>$, see |crv-size_t2|. +Also declared in$<string.h>$, see |crv-size_t3|. +Also declared in$<time.h>$, see |crv-size_t4|. +Also declared in$<stdio.h>$, see |crv-size_t5|. + + +wchar_t Type *crv-wchar_t3* +------------ +This data type is used as the base type for wide character strings. +It's range of values can represent distinct codes for all members of the +largest extended character set specified among the supported locales. +Also declared in$<stddef.h>$, see |crv-wchar_t|. +Also declared in$<stdlib.h>$, see |crv-wchar_t2|. + + +wint_t Type *crv-wint_t2* +----------- +This is a data type used for parameters and variables that contain a single +wide character. +Also declared in$<wctype.h>$, see |crv-wint_t|. + + + + +------------------------------------------------------------------------------ +II.24.2 Macros *crv-libWCHMac* + +Quicklink: + $NULL$ Macro |crv-NULL6| + $WCHAR_MIN$ Macro |crv-WCHAR_MIN2| + $WCHAR_MAX$ Macro |crv-WCHAR_MAX2| + $WEOF$ Macro |crv-WEOF2| + + +NULL Macro *crv-NULL6* +---------- +Expands to an implementation-defined null pointer constant. +Also defined in$<stddef.h>$, see |crv-NULL|. +Also defined in$<stdlib.h>$, see |crv-NULL2|. +Also defined in$<string.h>$, see |crv-NULL3|. +Also defined in$<time.h>$, see |crv-NULL4|. +Also defined in$<stdio.h>$, see |crv-NULL5|. + + +WCHAR_MIN Macro *crv-WCHAR_MIN2* +WCHAR_MAX Macro *crv-WCHAR_MAX2* +--------------- +Minimum and maximum value representable by an object of type$wchar_t$. +Also defined in$<wctype.h>$, see |crv-libWCHAR_MIN|, |crv-libWCHAR_MAX|. + + +WEOF Macro *crv-WEOF2* +---------- +This macro expands to an expression of type$wint_t$that is returned by a +number of wide stream functions to indicate an end-of-file condition, or some +other error situation. +Also declared in$<wctype.t>$, see |crv-libWEOF|. + + + + +------------------------------------------------------------------------------ +II.24.3 Formatted Input/Output *crv-libWCHIO* + +Quicklink: + $fwprintf()$ Func |crv-fwprintf| + $swprintf()$ Func |crv-swprintf| + $wprintf()$ Func |crv-wprintf| + $wscanf()$ Func |crv-wscanf| + $fwscanf()$ Func |crv-fwscanf| + $swscanf()$ Func |crv-swscanf| + $vfwprintf()$ Func |crv-vfwprintf| + $vswprintf()$ Func |crv-vswprintf| + $vwprintf()$ Func |crv-vwprintf| + $vfwscanf()$ Func |crv-vfwscanf| + $vswscanf()$ Func |crv-vswscanf| + $vwscanf()$ Func |crv-vwscanf| + + + +wprintf() Function *crv-wprintf* +------------------ +Synopsis~ + $#include <wchar.h>$ + $int wprintf(const wchar_t *format, ...);$ + +Return~ +<0: output error occurred +>= 0: number of transmitted characters + +Description~ +This function prints the optional arguments under the control of the wide +format string$format$to the standard output stream$stdout$. +For format string see |crv-libSIOHIOFout|. + + + +fwprintf() Function *crv-fwprintf* +------------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $int fwprintf(FILE *stream, const wchar_t *format, ...);$ + +Return~ +<0: output error occurred +>= 0: number of transmitted characters + +Description~ +This function is just like$wprintf()$, except that the output is written to +the stream$stream$instead of standard output stream$stdout$. + + + +swprintf() Function *crv-swprintf* +------------------- +Synopsis~ + $#include <wchar.h>$ + $int swprintf(wchar_t *s, size_t size, const wchar_t *format, ...);$ + +Return~ +The return value is the number of characters generated for the given input, +excluding the trailing null. If not all output fits into the provided +buffer or an error occurred a negative value is returned. + +Description~ +This is like$wprintf()$, except that the output is stored in the wide +character array$s$instead of written to a stream. A null wide character is +written to mark the end of the string. The$size$argument specifies the maximum +number of characters to produce. The trailing null character is counted +towards this limit. + + + +vwprintf() Function *crv-vwprintf* +------------------- +Synopsis~ + $#include <stdarg.h>$ + $#include <wchar.h>$ + $int vwprintf(const wchar_t *format, va_list ap);$ + +Return~ + +Description~ +This function is similar to$wprintf()$except that, instead of taking a +variable number of arguments directly, it takes an argument list pointer$ap$. + + + +vfwprintf() Function *crv-vfwprintf* +-------------------- +Synopsis~ + $#include <stdarg.h>$ + $#include <stdio.h>$ + $#include <wchar.h>$ + $int vfwprintf(FILE *stream, const wchar_t *format, va_list ap);$ + +Return~ + +Description~ +This is the equivalent of$fwprintf()$with the variable argument list specified +directly as for$vwprintf()$. + + + +vswprintf() Function *crv-vswprintf* +-------------------- +Synopsis~ + $#include <stdarg.h>$ + $#include <stdio.h>$ + $#include <wchar.h>$ + $int vswprintf(wchar_t *s, size_t size, const wchar_t *format, va_list ap);$ + +Return~ + +Description~ +This is the equivalent of$swprintf()$with the variable argument list specified +directly as for$vwprintf()$. + + + +wscanf() Function *crv-wscanf* +----------------- +Synopsis~ + $#include <wchar.h>$ + $int wscanf(const wchar_t *format, ...);$ + +Return~ +The return value is normally the number of successful assignments. If an +end-of-file condition is detected before any matches are performed, including +matches against whitespace and literal characters in the template, then$WEOF$ +is returned. + +Description~ +The$wscanf()$function reads formatted input from the stream$stdin$under the +control of the format string$format$. The optional arguments are pointers to +the places which receive the resulting values. +For format string see |crv-libSIOHIOFin|. + + + +fwscanf() Function *crv-fwscanf* +------------------ +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $int fwscanf(FILE *stream, const wchar_t *format, ...);$ + +Return~ + +Description~ +This function is just like$wscanf()$, except that the input is read from the +stream$stream$instead of$stdin$. + + + +swscanf() Function *crv-swscanf* +------------------ +Synopsis~ + $#include <wchar.h>$ + $int swscanf (const wchar_t *ws, const char *format, ...);$ + +Return~ + +Description~ +This is like$wscanf()$, except that the characters are taken from the +null-terminated string$ws$instead of from a$stream$. Reaching the end of the +string is treated as an end-of-file condition. + +The behavior of this function is undefined if copying takes place between +objects that overlap. + + + +vwscanf() Function *crv-vwscanf* +------------------ +Synopsis~ + $#include <stdarg.h>$ + $#include <wchar.h>$ + $int vwscanf(const wchar_t *format, va_list ap);$ + +Return~ + +Description~ +This function is similar to$wscanf()$, but instead of taking a variable number +of arguments directly, it takes an argument list pointer ap of type$va_list$. + + + +vfwscanf() Function *crv-vfwscanf* +------------------- +Synopsis~ + $#include <stdarg.h>$ + $#include <stdio.h>$ + $#include <wchar.h>$ + $int vfwscanf(FILE *stream, const wchar_t *format, va_list ap);$ + +Return~ + +Description~ +This is the equivalent of$fwscanf()$with the variable argument list specified +directly as for$vwscanf()$. + + + +vswscanf() Function *crv-vswscanf* +------------------- +Synopsis~ + $#include <stdarg.h>$ + $#include <wchar.h>$ + $int vswscanf(const wchar_t *s, const wchar_t *format, va_list ap);$ + +Return~ + +Description~ +This is the equivalent of$swscanf()$with the variable argument list specified +directly as for$vwscanf()$. + + + + +------------------------------------------------------------------------------ +II.24.4 Character Input/Output *crv-libWCHCIO* + +Quicklink: + $fgetwc()$ Func |crv-fgetwc| + $fgetws()$ Func |crv-fgetws| + $getwc()$ Macro |crv-getwc| + $getwchar()$ Macro |crv-getwchar| + $ungetwc()$ Func |crv-ungetwc| + $fputwc()$ Func |crv-fputwc| + $fputws()$ Func |crv-fputws| + $putwc()$ Macro |crv-putwc| + $putwchar()$ Macro |crv-putwchar| + $fwide()$ Func |crv-fwide| + + + +fgetwc() Function *crv-fgetwc* +----------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $wint_t fgetwc(FILE *stream);$ + +Return~ +wide character read from stream, or$WEOF$if an error or an end-of-file +condition occurred + +Description~ +This function reads the next wide character from the stream$stream$and returns +its value. + + + +fgetws() Function *crv-fgetws* +----------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $wchar_t *fgetws(wchar_t *ws, int count, FILE *stream);$ + +Return~ +If the system is already at end of file when$fgetws()$is called, then the +contents of the array$ws$are unchanged and a null pointer is returned. A null +pointer is also returned if a read error occurs. Otherwise, the return value +is the pointer$ws$. + +Description~ +This function reads wide characters from the stream$stream$up to and including +a newline character and stores them in the string$ws$, adding a null wide +character to mark the end of the string.$count$wide characters worth of space +in$ws$must be supplied, but the number of characters read is at most +$count - 1$. The extra character space is used to hold the null wide character +at the end of the string. + + + +getwc() Macro *crv-getwc* +------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $wint_t getwc(FILE *stream);$ + +Return~ +wide character read from stream, or$WEOF$if an error or an end-of-file +condition occurred + +Description~ +This is just like$fgetwc()$, except that it is permissible for it to be +implemented as a macro that evaluates the$stream$argument more than once. +$getwc()$can be highly optimized, so it is usually the best function to use +to read a single wide character. + + + +getwchar() Macro *crv-getwchar* +---------------- +Synopsis~ + $#include <wchar.h>$ + $wint_t getwchar(void);$ + +Return~ +wide character read from stream, or$WEOF$if an error or an end-of-file +condition occurred + +Description~ +This function is equivalent to$getwc()$with$stdin$as the value of the stream +argument. + + + +ungetwc() Function *crv-ungetwc* +------------------ +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $wint_t ungetwc(wint_t wc, FILE *stream);$ + +Return~ + +Description~ +The$ungetwc()$function behaves just like$ungetc()$just that it pushes back a +wide character. + + + +fputwc() Function *crv-fputwc* +----------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $wint_t fputwc(wchar_t wc, FILE *stream);$ + +Return~ +$WEOF$is returned if a write error occurs; otherwise the character$wc$is +returned + +Description~ +This function writes the wide character$wc$to the stream$stream$. + + + +fputws() Function *crv-fputws* +----------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $int fputws(const wchar_t *ws, FILE *stream);$ + +Return~ +$WEOF$is returned if a write error occurs, otherwise a non-negative value + +Description~ +The function$fputws()$writes the wide character string$ws$to the stream +$stream$. The terminating null character is not written. This function does +not add a newline character, either. It outputs only the characters in the +string. + + + +putwc() Macro *crv-putwc* +------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $wint_t putwc(wchar_t wc, FILE *stream);$ + +Return~ +$WEOF$is returned if a write error occurs; otherwise the character$wc$is +returned + +Description~ +This is just like$fputwc()$, except that it can be implement as a macro, +making it faster. One consequence is that it may evaluate the$stream$argument +more than once, which is an exception to the general rule for macros.$putwc()$ +is usually the best function to use for writing a single wide character. + + + +putwchar() Macro *crv-putwchar* +---------------- +Synopsis~ + $#include <wchar.h>$ + $wint_t putwchar(wchar_t wc);$ + +Return~ +$WEOF$is returned if a write error occurs; otherwise the character$wc$is +returned + +Description~ +The$putwchar()$function is equivalent to$putwc()$with$stdout$as the value +of the stream argument. + + + +fwide() Function *crv-fwide* +---------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $int fwide(FILE *stream, int mode);$ + +Return~ +The$fwide()$function returns a negative value, zero, or a positive value if +the stream is narrow, not at all, or wide oriented respectively. + +Description~ +The$fwide()$function can be used to set and query the state of the orientation +of the stream$stream$. If the$mode$parameter has a positive value the streams +get wide oriented, for negative values narrow oriented. It is not possible +to overwrite previous orientations with$fwide()$. I.e., if the stream$stream$ +was already oriented before the call nothing is done. + +If$mode$is zero the current orientation state is queried and nothing is +changed. + + + + +------------------------------------------------------------------------------ +II.24.5 String Utilities *crv-libWCHStrng* + + +II.24.5.1 Numeric Conversions *crv-libWCHNum* +------------------------------ + +Quicklink: + $wcstod()$ Func |crv-wcstod| + $wcstof()$ Func |crv-wcstof| + $wcstold()$ Func |crv-wcstold| + $wcstol()$ Func |crv-wcstol| + $wcstoll()$ Func |crv-wcstoll| + $wcstoul()$ Func |crv-wcstoul| + $wcstoull()$ Func |crv-wcstoull| + + + +wcstod() Function *crv-wcstod* +wcstof() Function *crv-wcstof* +wcstold() Function *crv-wcstold* +------------------ +Synopsis~ + $#include <wchar.h>$ + $double wcstod(const wchar_t *restrict string, wchar_t **restrict tailptr);$ + $float wcstof(const wchar_t *string, wchar_t **tailptr);$ + $long double wcstold(const wchar_t *string, wchar_t **tailptr);$ + +Description~ +The$wcstod()$,$wcstof()$, and$wcstol()$functions are equivalent in nearly all +aspect to the$strtod()$,$strtof()$, and$strtold()$functions but it handles +wide character string. + + + +wcstol() Function *crv-wcstol* +wcstoll() Function *crv-wcstoll* +wcstoul() Function *crv-wcstoul* +wcstoull() Function *crv-wcstoull* +------------------- +Synopsis~ + $#include <wchar.h>$ + $long int wcstol(const wchar_t *restrict string,$ + $wchar_t **restrict tailptr, int base);$ + $long long int wcstoll(const wchar_t *restrict string,$ + $wchar_t **restrict tailptr, int base);$ + $unsigned long int wcstoul(const wchar_t *restrict string,$ + $wchar_t **restrict tailptr, int base);$ + $unsigned long long int wcstoull(const wchar_t *restrict string,$ + $wchar_t **restrict tailptr, int base);$ + +Description~ +The$wcstol()$,$wcstoll()$,$wcstoul()$,$wcstoull()$functions are equivalent in +nearly all aspectes to$strtol()$,$strstoll()$,$strtoul()$,$strtoull()$ +functions but handels wide character string. + + + + +II.24.5.2 Copying *crv-libWCHCopy* +------------------ + +Quicklink: + $wcscpy()$ Func |crv-wcscpy| + $wcsncpy()$ Func |crv-wcsncpy| + $wmemcpy()$ Func |crv-wmemcpy| + $wmemmove()$ Func |crv-wmemmove| + + +wcscpy() Function *crv-wcscpy* +----------------- +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wcscpy(wchar_t *restrict wto, const wchar_t *restrict wfrom);$ + +Return~ +value is the value of$wto$ + +Description~ +This copies wide characters from the string$wfrom$(up to and including the +terminating null wide character) into the string$wto$. Like$wmemcpy()$, this +function has undefined results if the strings overlap. + + + +wcsncpy() Function *crv-wcsncpy* +------------------ +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wcsncpy(wchar_t *restrict wto, const wchar_t *restrict wfrom,$ + $size_t size);$ + +Return~ +value is the value of$wto$ + +Description~ +This function is similar to$wcscpy()$but always copies exactly$size$wide +characters into$wto$. + +If the length of$wfrom$is more than$size$, then$wcsncpy()$copies just the +first$size$wide characters. Note that in this case there is no null +terminator written into$wto$. + +If the length of$wfrom$is less than$size$, then$wcsncpy()$copies all of +$wfrom$, followed by enough null wide characters to add up to$size$wide +characters in all. + +The behavior of$wcsncpy()$is undefined if the strings overlap. + + + +wmemcpy() Function *crv-wmemcpy* +------------------ +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wmemcpy(wchar_t *restrict wto, const wchar_t *restruct wfrom,$ + $size_t size);$ + +Return~ +value is the value of$wto$ + +Description~ +The$wmemcpy()$function copies$size$wide characters from the object beginning +at$wfrom$into the object beginning at$wto$. The behavior of this function is +undefined if the two arrays$wto$and$wfrom$overlap; use$wmemmove()$instead if +overlapping is possible. + + + +wmemmove() Function *crv-wmemmove* +------------------- +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wmemmove(wchar *wto, const wchar_t *wfrom, size_t size);$ + +Return~ +value is the value of$wto$ + +Description~ +This function copies the$size$wide characters at$wfrom$into the$size$wide +characters at$wto$, even if those two blocks of space overlap. In the case of +overlap,$memmove()$is careful to copy the original values of the wide +characters in the block at$wfrom$, including those wide characters which also +belong to the block at$wto$. + + + + +II.24.5.3 Concatenation *crv-libWCHConcat* +------------------------ + +Quicklink: + $wcscat()$ Func |crv-wcscat| + $wcsncat()$ Func |crv-wcsncat| + + +wcscat() Function *crv-wcscat* +----------------- +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wcscat(wchar_t *restrict wto, const wchar_t *restrict wfrom);$ + +Return~ +value is the value of$wto$ + +Description~ +The$wcscat()$function is similar to$wcscpy()$, except that the characters +fromw$from$are concatenated or appended to the end of$wto$, instead of +overwriting it. That is, the first character from$wfrom$overwrites the null +character marking the end of$wto$. + + + +wcsncat() Function *crv-wcsncat* +------------------ +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wcsncat(wchar_t *restrict wto, const wchar_t *restrict wfrom,$ + $size_t size);$ + +Return~ +value is the value of$wto$ + +Description~ +This function is like$wcscat()$except that not more than$size$characters +from$from$are appended to the end of$wto$. A single null character is also +always appended to$wto$, so the total allocated size of$wto$ must be at least +$size + 1$bytes longer than its initial length. + + + + +II.24.5.4 Comparison *crv-libWCHCmp* +--------------------- + +Quicklink: + $wcscmp()$ Func |crv-wcscmp| + $wcscoll()$ Func |crv-wcscoll| + $wcsncmp()$ Func |crv-wcsncmp| + $wcsxfrm()$ Func |crv-wcsxfrm| + $wmemcmp()$ Func |crv-wmemcmp| + + + +wcscmp() Function *crv-wcscmp* +----------------- +Synopsis~ + $#include <wchar.h>$ + $int wcscmp(const wchar_t *ws1, const wchar_t *ws2);$ + +Return~ +The value returned is greater than, equal to, or less than zero, accordingly +as the string pointed to by$ws1$is greater than, equal to, or less than the +string pointed to by$ws2$. + +A consequence of the ordering used by$wcscmp()$is that if$ws1$is an initial +substring of$ws2$, then$ws1$is considered to be "less than"$ws2$. + +Description~ +The$wcscmp()$function compares the wide character string$ws1$against$ws2$. + + + +wcscoll() Function *crv-wcscoll* +------------------ +Synopsis~ + $#include <wchar.h>$ + $int wcscoll(const wchar_t *ws1, const wchar_t *ws2);$ + +Return~ +The value returned is greater than, equal to, or less than zero, accordingly +as the string pointed to by$ws1$is greater than, equal to, or less than the +string pointed to by$ws2$. + +Description~ +The$wcscoll()$function is similar to$wcscmp()$but uses the collating sequence +of the current locale for collation (the$LC_COLLATE$locale). + + + +wcsncmp() Function *crv-wcsncmp* +------------------ +Synopsis~ + $#include <wchar.h>$ + $int wcsncmp(const wchar_t *ws1, const wchar_t *ws2, size_t size);$ + +Return~ +The value returned is greater than, equal to, or less than zero, accordingly +as the string pointed to by$ws1$is greater than, equal to, or less than the +string pointed to by$ws2$. + +Description~ +This function is the similar to$wcscmp()$, except that no more than$size$wide +characters are compared. In other words, if the two strings are the same in +their first$size$wide characters, the return value is zero. + + + +wcsxfrm() Function *crv-wcsxfrm* +------------------ +Synopsis~ + $#include <wchar.h>$ + $size_t wcsxfrm(wchar_t *restrict wto, const wchar_t *wfrom, size_t size);$ + +Description~ +This function is the similar to$strxfrm()$but handles wide characters. +See |crv-libstrxfrm| for further information on$strxfrm()$. + + + +wmemcmp() Function *crv-wmemcmp* +------------------ +Synopsis~ + $#include <wchar.h>$ + $int wmemcmp(const wchar_t *a1, const wchar_t *a2, size_t size);$ + +Return~ +The value returned is greater than, equal to, or less than zero, accordingly +as the string pointed to by$a1$is greater than, equal to, or less than the +string pointed to by$a2$. + +Description~ +The function$wmemcmp()$compares the$size$wide characters beginning at$a1$ +against the$size$wide characters beginning at$a2$. + + + + +II.24.5.5 Search *crv-libWCHSearch* +----------------- + +Quicklink: + $wcschr()$ Func |crv-wcschr| + $wcscspn()$ Func |crv-wcscspn| + $wcspbrk()$ Func |crv-wcspbrk| + $wcsrchr()$ Func |crv-wcsrchr| + $wcsspn()$ Func |crv-wcsspn| + $wcsstr()$ Func |crv-wcsstr| + $wcstok()$ Func |crv-wcstok| + $wmemchr()$ Func |crv-wmemchr| + + + +wcschr() Function *crv-wcschr* +----------------- +Synopsis~ + $#include <wchar.h>$ + $wchar_t * wcschr(const wchar_t *wstring, int wc);$ + +Description~ +This function is the similar to$strchr()$but handles wide character. + + + +wcscspn() Function *crv-wcscspn* +------------------ +Synopsis~ + $#include <wchar.h>$ + $size_t wcscspn(const wchar_t *wstring, const wchar_t *stopset);$ + +Description~ +This function is the similar to$strspn()$but handles wide character. + + + +wcspbrk() Function *crv-wcspbrk* +------------------ +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wcspbrk (const wchar_t *wstring, const wchar_t *stopset);$ + +Description~ +This function is the similar to$strpbrk()$but handles wide character. + + + +wcsrchr() Function *crv-wcsrchr* +------------------ +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wcsrchr (const wchar_t *wstring, wchar_t c);$ + +Description~ +This function is the similar to$strrchr()$but handles wide character. + + + +wcsspn() Function *crv-wcsspn* +----------------- +Synopsis~ + $#include <wchar.h>$ + $size_t wcsspn(const wchar_t *wstring, const wchar_t *skipset);$ + +Description~ +This function is the similar to$strspn()$but handles wide character. + + + +wcsstr() Function *crv-wcsstr* +----------------- +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wcsstr(const wchar_t *haystack, const wchar_t *needle);$ + +Description~ +This function is the similar to$strstr()$but handles wide character. + + + +wcstok() Function *crv-wcstok* +----------------- +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wcstok(wchar_t *newstring, const char *delimiters);$ + +Description~ +This function is the similar to$strtok()$but handles wide character. + + + +wmemchr() Function *crv-wmemchr* +------------------ +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wmemchr(const wchar_t *block, wchar_t wc, size_t size);$ + +Description~ +This function is the similar to$memchr()$but handles wide character. + + + + +II.24.5.6 Miscellaneous *crv-libWCHMisc* +------------------------ + +Quicklink: + $wmemset()$ Func |crv-wmemset| + $wcslen()$ Func |crv-wcslen| + + + +wcslen() Function *crv-wcslen* +----------------- +Synopsis~ + $#include <wchar.h>$ + $size_t wcslen(const wchar_t *ws);$ + +Description~ +This function is the similar to$strlen()$but handles wide character. + + + +wmemset() Function *crv-wmemset* +------------------ +Synopsis~ + $#include <wchar.h>$ + $wchar_t *wmemset(wchar_t *block, wchar_t wc, size_t size);$ + +Description~ +This function is the similar to$memset()$but handles wide character. + + + + +------------------------------------------------------------------------------ +II.24.6 Time Conversions *crv-libWCHTimeConv* + +Quicklink: + $wcsftime()$ Func |crv-wcsftime| + + + +wcsftime() Function *crv-wcsftime* +------------------- +Synopsis~ + $#include <time.h>$ + $#include <wchar.h>$ + $size_t wcsftime(wchar_t *s, size_t size, const wchar_t *template,$ + $const struct tm *brokentime);$ + +Description~ +This function is the similar to$strftime()$but handles wide character. + + + + +------------------------------------------------------------------------------ +II.24.7 Character Conversions *crv-libWCHCharConv* + +Quicklink: + $btowc()$ Func |crv-btowc| + $wctob()$ Func |crv-wctob| + $mbsinit()$ Func |crv-mbsinit| + $mbrlen()$ Fucn |crv-mbrlen| + $mbrtowc()$ Func |crv-mbrtowc| + $wcrtomb()$ Func |crv-wcrtomb| + $mbsrtowc()$ Func |crv-mbsrtowc| + $wcsrtombs()$ Func |crv-wcsrtombs| + + + +btowc() Function *crv-btowc* +---------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $wint_t btowc(int c);$ + +Return~ +If ($unsigned char$)$c$is no valid single byte multibyte character or if$c$ +is$EOF$, the function returns$WEOF$. Otherwise the wide character +representation of$c$is returned. + +Description~ +The$btowc()$function ("byte to wide character") converts a valid single byte +character$c$in the initial shift state into the wide character equivalent +using the conversion rules from the currently selected locale of the$LC_CTYPE$ +category. + + + +wctob() Function *crv-wctob* +---------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $int wctob(wint_t c);$ + +Return~ +If the multibyte representation for this character in the initial state is +exactly one byte long, the return value of this function is this character. +Otherwise the return value is$EOF$. + +Description~ +The$wctob()$function ("wide character to byte") takes as the parameter a valid +wide character. + + + +mbsinit() Function *crv-mbsinit* +------------------ +Synopsis~ + $#include <wchar.h>$ + $int mbsinit(const mbstate_t *ps);$ + +Return~ +If$ps$is a null pointer or the object is in the initial state the return value +is nonzero. Otherwise it is zero. + +Description~ +The$mbsinit()$function determines whether the state object pointed to by$ps$is +in the initial state. + + + +mbrlen() Fucntion *crv-mbrlen* +----------------- +Synopsis~ + $#include <wchar.h>$ + $size_t mbrlen(const char *restrict s, size_t n, mbstate_t *ps);$ + +Return~ +see description + +Description~ +The$mbrlen()$function ("multibyte restartable length") computes the number of +at most$n$bytes starting at$s$, which form the next valid and complete +multibyte character. + +If the next multibyte character corresponds to the NUL wide character, the +return value is 0. If the next$n$bytes form a valid multibyte character, the +number of bytes belonging to this multibyte character byte sequence is +returned. + +If the the first$n$bytes possibly form a valid multibyte character but the +character is incomplete, the return value is$(size_t) - 2$. Otherwise the +multibyte character sequence is invalid and the return value +is$(size_t) - 1$. + +The multibyte sequence is interpreted in the state represented by the object +pointed to by$ps$. If$ps$ is a null pointer, a state object local +to$mbrlen()$is used. + + + +mbrtowc() Function *crv-mbrtowc* +------------------ +Synopsis~ + $#include <wchar.h>$ + $size_t mbrtowc(wchar_t *restrict pwc, const char *restrict s,$ + $size_t n, mbstate_t *restrict ps);$ + +Return~ +see description + +Description~ +The$mbrtowc()$function ("multibyte restartable to wide character") converts +the next multibyte character in the string pointed to by$s$into a wide +character and stores it in the wide character string pointed to by$pwc$. The +conversion is performed according to the locale currently selected for +the$LC_CTYPE$category. If the conversion for the character set used in the +locale requires a state, the multibyte string is interpreted in the state +represented by the object pointed to by$ps$. If$ps$is a null pointer, a +static, internal state variable used only by the$mbrtowc()$function is used. + +If the next multibyte character corresponds to the NUL wide character, the +return value of the function is 0 and the state object is afterwards in the +initial state. If the next$n$or fewer bytes form a correct multibyte +character, the return value is the number of bytes starting from$s$that form +the multibyte character. The conversion state is updated according to the +bytes consumed in the conversion. In both cases the wide character (either +the L'\0' or the one found in the conversion) is stored in the string +pointed to by$pwc$if$pwc$is not null. + +If the first$n$bytes of the multibyte string possibly form a valid multibyte +character but there are more than$n$bytes needed to complete it, the return +value of the function is$(size_t) - 2$and no value is stored. Please note +that this can happen even if$n$has a value greater than or equal +to$MB_CUR_MAX$since the input might contain redundant shift sequences. + +If the first$n$bytes of the multibyte string cannot possibly form a valid +multibyte character, no value is stored, the global variable$errno$is set to +the value$EILSEQ$, and the function returns$(size_t) - 1$. The conversion +state is afterwards undefined. + + + +wcrtomb() Function *crv-wcrtomb* +----------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $size_t wcrtomb(char *restrict s, wchar_t wc, mbstate_t *restrict ps);$ + +Return~ +see description + +Description~ +The$wcrtomb()$function ("wide character restartable to multibyte") converts a +single wide character into a multibyte string corresponding to that wide +character. + +If$s$is a null pointer, the function resets the state stored in the objects +pointed to by$ps$(or the internal$mbstate_t$object) to the initial state. This +can also be achieved by a call like this: + + $wcrtombs(temp_buf, L'\0', ps)$ + +since, if$s$is a null pointer,$wcrtomb()$performs as if it writes into an +internal buffer, which is guaranteed to be large enough. + +If$wc$is the NUL wide character,$wcrtomb()$emits, if necessary, a shift +sequence to get the state$ps$into the initial state followed by a single +$NULL$byte, which is stored in the string$s$. + +Otherwise a byte sequence (possibly including shift sequences) is written into +the string$s$. This only happens if$wc$is a valid wide character. If$wc$is no +valid wide character, nothing is stored in the strings$s$,$errno$is set +to$EILSEQ$, the conversion state in$ps$is undefined and the return value +is$(size_t) - 1$. + +If no error occurred the function returns the number of bytes stored in the +string$s$. This includes all bytes representing shift sequences. + + + +mbsrtowc() Function *crv-mbsrtowc* +------------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $size_t mbsrtowcs(wchar_t *restrict dst, const char **restrict src,$ + $size_t len, mbstate_t *restrict ps);$ + +Return~ +see description + +Description~ +The$mbsrtowcs()$function ("multibyte string restartable to wide character +string") converts an NUL-terminated multibyte character string at$*src$into an +equivalent wide character string, including the NUL wide character at the end. +The conversion is started using the state information from the object pointed +to by$ps$or from an internal object of$mbsrtowcs()$if$ps$is a null pointer. +Before returning, the state object is updated to match the state after the +last converted character. The state is the initial state if the terminating +NUL byte is reached and converted. + +If$dst$is not a null pointer, the result is stored in the array pointed to +by$dst$; otherwise, the conversion result is not available since it is stored +in an internal buffer. + +If$len$wide characters are stored in the array$dst$before reaching the end of +the input string, the conversion stops and$len$is returned. If$dst$is a null +pointer,$len$is never checked. + +Another reason for a premature return from the function call is if the input +string contains an invalid multibyte sequence. In this case the global +variable$errno$is set to$EILSEQ$and the function returns$(size_t) - 1$. + +In all other cases the function returns the number of wide characters +converted during this call. If$dst$is not null,$mbsrtowcs()$stores in the +pointer pointed to by$src$either a null pointer (if the NUL byte in the +input string was reached) or the address of the byte following the last +converted multibyte character. + + + +wcsrtombs() Function *crv-wcsrtombs* +-------------------- +Synopsis~ + $#include <stdio.h>$ + $#include <wchar.h>$ + $size_t wcsrtombs(char *restrict dst, const wchar_t **restrict src,$ + $size_t len, mbstate_t *restrict ps);$ + +Return~ +see description + +Description~ +The$wcsrtombs()$function ("wide character string restartable to multibyte +string") converts the NUL-terminated wide character string at$*src$ into an +equivalent multibyte character string and stores the result in the array +pointed to by$dst$. The NUL wide character is also converted. The conversion +starts in the state described in the object pointed to by$ps$or by a state +object locally to$wcsrtombs()$in case$ps$is a null pointer. If$dst$is a +null pointer, the conversion is performed as usual but the result is not +available. If all characters of the input string were successfully converted +and if$dst$is not a null pointer, the pointer pointed to by$src$gets assigned +a null pointer. + +If one of the wide characters in the input string has no valid multibyte +character equivalent, the conversion stops early, sets the global variable +$errno$to$EILSEQ$, and returns$(size_t) - 1$. + +Another reason for a premature stop is if$dst$is not a null pointer and the +next converted character would require more than$len$bytes in total to the +array$dst$. In this case (and if$dest$is not a null pointer) the pointer +pointed to by$src$is assigned a value pointing to the wide character right +after the last one successfully converted. + +Except in the case of an encoding error the return value of the$wcsrtombs()$ +function is the number of bytes in all the multibyte character sequences +stored in$dst$. Before returning the state in the object pointed to by$ps$ +(or the internal object in case$ps$is a null pointer) is updated to reflect +the state after the last conversion. The state is the initial shift state +in case the terminating NUL wide character was converted. + + + + +============================================================================== +II.25 <wctype.h> Wide Character *crv-libWctypeH* + +In this section wide character classification and mapping utilities are +described. + + +------------------------------------------------------------------------------ +II.25.1 Types *crv-libWTHType* + +Quicklink: + $wctrans_t$ Type |crv-wctrans_t| + $wctype_t$ Type |crv-wctype_t| + $wint_t$ Type |crv-wint_t| + + + +wint_t Type *crv-wint_t* +----------- +This is a data type used for parameters and variables that contain a single +wide character. +Also declared in$<wchar.h>$, see |crv-libwint_t2|. + + + +wctrans_t Type *crv-wctrans_t* +-------------- +This data type is defined as a scalar type which can hold a value representing +the locale-dependent character mapping. There is no way to construct such a +value apart from using the return value of the$wctrans()$function. + + + +wctype_t Type *crv-wctype_t* +------------- +This type can hold a value which represents a character class. The only +defined way to generate such a value is by using the$wctype()$function. + + + + +------------------------------------------------------------------------------ +II.25.2 Macros *crv-libWTHMac* + + +WEOF Macro *crv-WEOF* +---------- +This macro expands to an expression of type$wint_t$that is returned by a +number of wide stream functions to indicate an end-of-file condition, or some +other error situation. +Also declared in$<wchar.t>$, see |crv-WEOF2|. + + + +------------------------------------------------------------------------------ +II.25.3 Classification *crv-libWTHClass* + + +II.25.3.1 Wide Character *crv-libWTHCwide* +------------------------- + +Quicklink: + $iswalnum()$ Func |crv-iswalnum| + $iswalpha()$ Func |crv-iswalpha| + $iswblank()$ Func |crv-iswblank| + $iswcntrl()$ Func |crv-iswcntrl| + $iswdigit()$ Func |crv-iswdigit| + $iswgraph()$ Func |crv-iswgraph| + $iswlower()$ Func |crv-iswlower| + $iswprint()$ Func |crv-iswprint| + $iswpunct()$ Func |crv-iswpunct| + $iswspace()$ Func |crv-iswspace| + $iswupper()$ Func |crv-iswupper| + $iswxdigit()$ Func |crv-iswxdigit| + + + +iswalnum() Function *crv-iswalnum* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswalnum(wint_t wc);$ + +Description~ +This function returns a nonzero value if$wc$is an alphanumeric character (a +letter or number); in other words, if either$iswalpha()$or$iswdigit()$is true +of a character, then$iswalnum()$is also true. + + + +iswalpha() Function *crv-iswalpha* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswalpha(wint_t wc);$ + +Description~ +Returns true if$wc$is an alphabetic character (a letter). If$iswlower()$or +$iswupper()$is true of a character, then$iswalpha()$is also true. + + + +iswblank() Function *crv-iswblank* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswblank(wint_t wc);$ + +Description~ +Returns true if$wc$is a blank character; that is, a space or a tab. + + + +iswcntrl() Function *crv-iswcntrl* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswcntrl(wint_t wc);$ + +Description~ +Returns true if$wc$is a control character (that is, a character that is not a +printing character). + + + +iswdigit() Function *crv-iswdigit* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswdigit(wint_t wc);$ + +Description~ +Returns true if$wc$is a digit (e.g., 0 through 9). Please note that this +function does not only return a nonzero value for decimal digits, but for +all kinds of digits. + + + +iswgraph() Function *crv-iswgraph* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswgraph(wint_t wc);$ + +Description~ +Returns true if$wc$is a graphic character; that is, a character that has a +glyph associated with it. The whitespace characters are not considered +graphic. +In other words: returns true if$iswprint()$is true and if$iswspace()$is false. + + + +iswlower() Function *crv-iswlower* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswlower(wint_t wc);$ + +Description~ +Returns true if$wc$is a lower-case letter. + + + +iswprint() Function *crv-iswprint* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswprint(wint_t wc);$ + +Description~ +Returns true if$wc$is a printing character. Printing characters include all +the graphic characters, plus the space (" ") character. + + + +iswpunct() Function *crv-iswpunct* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswpunct(wint_t wc);$ + +Description~ +Returns true if$wc$is a punctuation character. This means any printing +character that is not alphanumeric or a space character. + + + +iswspace() Function *crv-iswspace* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswspace(wint_t wc);$ + +Description~ +Returns true if$wc$is a whitespace character. In the standard "C" locale, +$iswspace()$returns true for only the standard whitespace characters: + + $L' '$ space + $L'\f'$ formfeed + $L'\n'$ newline + $L'\r'$ carriage return + $L'\t'$ horizontal tab + $L'\v'$ vertical tab + + + +iswupper() Function *crv-iswupper* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswupper(wint_t wc);$ + +Description~ +Returns true if$wc$is an upper-case letter. + + + +iswxdigit() Function *crv-iswxdigit* +-------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswxdigit(wint_t wc);$ + +Description~ +Returns true if$wc$is a hexadecimal digit. Hexadecimal digits include the +normal decimal digits 0 through 9 and the letters A through F and a through f. + + + + + +II.25.3.2 Extensible Wide Char *crv-libWTHCextens* +------------------------------- + +Quicklink: + $iswctype()$ Func |crv-iswctype| + $wctype()$ Func |crv-wctype| + + +iswctype() Function *crv-iswctype* +------------------- +Synopsis~ + $#include <wctype.h>$ + $int iswctype(wint_t wc, wctype_t desc);$ + +Description~ +This function returns a nonzero value if$wc$is in the character class +specified by$desc$.$desc$must previously be returned by a successful call +to$wctype()$. + + + +wctype() Function *crv-wctype* +----------------- +Synopsis~ + $#include <wctype.h>$ + $wctype_t wctype(const char *property);$ + +Description~ +The$wctype()$returns a value representing a class of wide characters which is +identified by the string$property$. Beside some standard properties each +locale can define its own ones. In case no$property$with the given name is +known for the current locale selected for the$LC_CTYPE$category, the function +returns zero. + +The properties known in every locale are: +$"alnum"$ +$"alpha"$ +$"cntrl"$ +$"digit"$ +$"graph"$ +$"lower"$ +$"print"$ +$"punct"$ +$"space"$ +$"upper"$ +$"xdigit"$ + + + +------------------------------------------------------------------------------ +II.25.4 Mapping *crv-libWTHMap* + + +II.25.4.1 Wide Character *crv-libWTHMwide* +------------------------- + +Quicklink: + $towlower()$ Func |crv-towlower| + $towupper()$ Func |crv-towupper| + + + +towlower() Function *crv-towlower* +------------------- +Synopsis~ + $#include <wctype.h>$ + $wint_t towlower(wint_t wc);$ + +Return~ +lower-case letter + +Description~ +If$wc$is an upper-case letter,$towlower()$returns the corresponding lower-case +letter. Otherwise$wc$is returned unchanged. + + + +towupper() Function *crv-towupper* +------------------- +Synopsis~ + $#include <wctype.h>$ + $wint_t towupper(wint_t wc);$ + +Return~ +upper-case letter + +Description~ +If$wc$is a lower-case letter,$towupper()$returns the corresponding upper-case +letter. Otherwise$wc$is returned unchanged. + + + + +II.25.4.2 Extensible Wide Char *crv-libWTHMextens* +------------------------------- + +Quicklink: + $towctrans()$ Func |crv-towctrans| + $wctrans()$ Func |crv-wctrans| + + + +towctrans() Function *crv-towctrans* +-------------------- +Synopsis~ + $#include <wctype.h>$ + $wint_t towctrans(wint_t wc, wctrans_t desc);$ + +Return~ +mapped value of$wc$ + +Description~ +This function maps the input character$wc$according to the rules of the +mapping for which$desc$is a descriptor, and returns the value it finds.$desc$ +must be obtained by a successful call to$wctrans()$. + + + +wctrans() Function *crv-wctrans* +------------------ +Synopsis~ + $#include <wctype.h>$ + $wctrans_t wctrans(const char *property);$ + +Return~ +0: mapping unknown +else: mapping known + +Description~ +This function has to be used to find out whether a named mapping is defined in +the current locale selected for the$LC_CTYPE$category. If the returned value +is non-zero, it can be used afterwards in calls to$towctrans()$. If the return +value is zero no such mapping is known in the current locale. + +Beside locale-specific mappings there are two mappings which are guaranteed +to be available in every locale: +$"tolower"$ +$"toupper"$ + + + + +============================================================================== +Appendix A GLOSSARY *crv-glossary* + + + *crv-gloAlignment* +Alignment Requirement that objects of a particular type be located on + storage boundaries with addresses that are particular + multiples of a byte address. + + *crv-gloArgument* +Argument An argument is an expression in a comma-separated list bounded + by parentheses in a function call or macro invocation. + + *crv-gloArray* +Array Set of elements that have the same data type. + + *crv-gloBinary* +Binary see Operator |crv-gloOperator| + + *crv-gloBlock* +Block C statements enclosed within braces ({...}) + + *crv-gloCompState* +Compound A compound statement is a block (see |crv-gloBlock|) +Statement + *crv-gloDataType* +Data Type see Type |crv-gloType| + + *crv-gloDeclaration* +Declaration A C construct that associates the attributes of a variable, + type or function with a name. A declaration does not need + memory, opposed to a definition (-> Definition). + + Example: +> + struct MeasVar { + int nCntr; + int nNumOfCycles; + float fResult; + }; +< + *crv-gloDefinition* +Definition A C construct that specifies the name, formal parameters, body + and return type of a function or that initializes and allocates + storage for a variable. A definition needs memory, opposed + to a declaration (-> Declaration). + + Example: +> + struct MeasVar mv; +< + *crv-gloExpression* +Expression An expression is a sequence of operators and operands that + specifies computation of a value or that designates an object + or function. + See |crv-gloOperand|, |crv-gloOperator| + + +False / True see |crv-gloTrueFalse| + + *crv-gloIdentifier* +Identifier An identifier is a name of a variable, function, macro... + Valid identifiers consists of uppercase and lowercase Latin + letters [a-z], [A-Z] and digits [0-9] and the underscore _. + They must start with a letter or underscore and must be + different to keywords. + + *crv-gloLifetime* +Lifetime The lifetime of a variable is the portion of program execution + during which storage is guaranteed to be reserved for it. + Throughout its lifetime a variable exists, has a fix address + and retains its last assigned value. + + *crv-gloLinkage* +Linkage Linkage is used to extend the scope of a variable or function + to the actual context. The keyword$extern$is used for that. + + *crv-gloLvalue* +lvalue A lvalue is an epxression that describes the location of an + object. The location is the object's lvalue. The object's rvalue + is the value stored at the location described by the lvalue. + + *crv-gloLvalueMod* +lvalue, A modifiable lvalue is an expression representing an object that +modifialbe can be changed. + A lvalue is a modifiable lvalue if: + - it has no array type + - it has no incomplete type + - it has no$const$type + - it has struct or union type and no$const$member + + *crv-gloMacro* +Macro An identifier that is equated to a text or symbolic expression + to which it is to be expanded by the preprocessor. + + *crv-gloObject* +Object An area of memory used by a variable, the contents represents + values. + + *crv-gloOperand* +Operand Parameter of an operator. + Example: + $a = b * c$ + + $*$is the operator, $a$and$b$are the operands + $b * c$is an expression + + *crv-gloOperator* +Operator An operator is used with operands to build an expression. + Example: + $a = b * c$ + + $*$is the operator, $a$and$b$are the operands + $b * c$is an expression + + An operator with two operands is called binary *crv-gloOpBinary* + e.g. *, /, +, ... + An operator with one operand is called unary. *crv-gloOpUnary* + e.g. - (sign), ++, --, .... + + *crv-gloParameter* +Parameter A parameter is the value that is passed to a function or macro. + In principle there are two ways parameters can be passed: + - By Value + This means that the function/macro works with a copy of + the parameter. Thus the value of the parameter can be + changed within the function/macro, but from caller's + view the parameter will keep its original value. + - By Reference + This means that the function/macro works with the + original parameter. Thus a caller of a function/macro + will "see" changes done to the parameter within + the function/macro. + C always uses pass by value. Use pointers to simulate a pass + by reference. + + *crv-gloPointer* +Pointer A variable that contains the address of a C element (variable, + structure, function) or memory area. + + *crv-gloPreprocessor* +Preprocessor A preprocessor is the first pass of a compiler. It does: + - read include files + - expand macros + - replace defines by their contents + - pass control directives to the compiler + + *crv-gloPromote* +Promote Promoting is a type cast from a "lower" type to a "higher" + type, e.g. from int to long. + + *crv-gloPrototype* +Prototype A function prototype is a declaration of a function that declares + the types of its parameters. + + *crv-gloRvalue* +rvalue A rvalue is the value of an expression. + See also lvalue |crv-gloLvalue|. + + *crv-gloScope* +Scope Scope is the visibility of a C element (variable, function) + within a program. The scope are the sections of a program where + an element can be referenced by name. The scope of an element + may be limited to file, function or block. + The scope of an element is determined from where it is defined. + If it is defined outside of a block, it has file scope. + If it is defined within a function prototype, it has function + scope. + If it is defined within a block, it has block scope. + + *crv-gloSemantics* +Semantics The relationships between symbols and their meanings. + + *crv-gloSideEffect* +Side-Effect During evaluation of an expression the value of a variable is + changed. Example: +> + b = (a = 2) * (a *= 3) +< + NOTE: To keep a program maintainable and readable don't use + side-effects. + + *crv-gloSignExtension* +Sign- Sign-extension is the filling of the left most bits with the +Extension state of the sign-bit when shifting right or when promoting. + + *crv-gloStatement* +Statement A statement is an expression followed by a semicolon. + see |crv-gloExpression| + + *crv-gloStructure* +Structure A set of elements that have possibly different data types. A + structure groups them together. + + *crv-gloSyntax* +Syntax A syntax describes the structure and order of the elements + of a language statement. In other words: it specifies how words + and symbols are put together to form a program. + + Example for Syntax versus Semantics: + The syntax rules of a human language could be: + - each word must be build with the characters a-z or A-Z + - words are separated by at least one space (" "). + - words must start either with an upper or lower character, + the following characters must be lower ones + - a sentence consists of words + - the first word of a sentence must start with an upper + character, the others with a lower one + - a sentence ends with a point (.) + + Following these rules, this would be a valid sentence: + "The weather is fine today." + + But this one would also be a syntactically correct + sentence: + "Thkds sdfasd ksdf dsf dfklsflsd." + + The semantics of a language connects words with meanings. + Thus the second sentence is a semantically incorrect sentence. + + So a language is defined by its semantics AND syntax. + The syntax defines how to form words and the semantics gives + words a meaning. + + *crv-gloToken* +Token Tokens are the minimal lexical elements of a programming + language. A token can be a keyword, an identifier, a constant, + a string literal, an operator or a punctuator. + + *crv-gloTrueFalse* +True / False In standard C an expression is FALSE if its value is 0, else + it is TRUE. The value of a logical TRUE is implementation + specific. + So never do something like + $if (IsWindowOpen() == TRUE)$ + instead of this do + $if (IsWindowOpen())$ + or + $if (IsWindowOpen() != FALSE)$ + + *crv-gloType* +Type The meaning of a value stored in an object or returned by a + function is determined by its type. + + *crv-gloTypeIncomplete* +Type, An incomplete type describes an object but lacks information to +incomplete determine its size. + E.g. an array type of unknown size is an incomplete type. + + *crv-gloTypeCast* +Type Cast A type cast is an operation in which an operand of one type is + converted to another type. In C the cast operator + is$(type-name)$. + Example: +> + int main(void) + { + int nVar = 42; + float fVar; + + fVar = (float)nVar; + } +< + *crv-gloUnary* +Unary see Operator |crv-gloOperator| + + *crv-gloVariable* +Variable Is the symbolic representation of a memory area. + + *crv-gloWhiteSpace* +White-Space A space, tab, carriage return, new line, vertical tab, or + formfeed character. + + + +============================================================================== +Appendix B BIBLIOGRAPHY *crv-bibliography* + +[1] "Erfolgreich programmieren mit C", 1. Auflage, 1985 + J. Anton Illik + SYBEX Verlag GmbH, Duesseldorf (Germany) + +[2] "Softwareentwicklung in C", 3. September 2001 + Klaus Schmaranz + Springer Verlag + +[3] "The GNU C Library Reference Manual", for Version 2.2.x of the GNU C + Library, Edition 0.10, last updated 2001-07-06 + Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002 + Free Software Foundation, Inc. + +[4] ISO/IEC 9899:1999(E) + International Standard + Programming languages - C + Published by American National Standards Institute + + + +============================================================================== +For Appendix C COPYRIGHT & LICENSES go to |crvdoc-copyright| + + +============================================================================== +For Appendix D AUTHOR go to |crvdoc-author| + + +============================================================================== +For Appendix E CREDITS go to |crvdoc-credits| + + +============================================================================== +For Appendix F HISTORY go to |crvdoc-history| + + + +------------------------------------------------------------------------------ + vim:tw=78:ts=4:ft=help:norl: diff --git a/.vim/doc/crefvimdoc.txt b/.vim/doc/crefvimdoc.txt new file mode 100755 index 0000000..34b600d --- /dev/null +++ b/.vim/doc/crefvimdoc.txt @@ -0,0 +1,1742 @@ +*crefvimdoc.txt* C-Reference Manual for Vim + Vim version 6.0 + + + *crefvimdoc* + Project CRefVim + ====================== + Version 1.0.4 + 27. Nov. 2004 + + + (c) 2002-2004 by Christian Habermann + christian (at) habermann-net (point) de + + + This is a C-reference manual especially designed for the text-editor Vim. + The scripts to view and access this manual within Vim are released under + the GNU General Public License (GPL), the documentation is released under + the GNU Free Documentation License (FDL). + + In the C-reference manual most parts of the chapter about the standard C + library are based on "The GNU C Library Reference Manual", edition 0.10. + "The GNU C Library Reference Manual" is copyright (c) 1993 - 2002 by the + Free Software Foundation, Inc. + Enhancements to this GNU-manual and modifications of this GNU-manual + in context with CRefVim were done by Christian Habermann. + + In the following this file (crefvimdoc.txt) and the C-reference manual + (crefvim.txt) is an entity called "document". + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.1 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "Free Software Needs Free Documentation" and + "GNU Lesser General Public License", the Front-Cover text being + "A Manual Supported by GNU", and with the Back-Cover text being + "You have freedom to copy and modify this manual.". + A copy of the license is included in the section entitled + "GNU Free Documentation License". + + + + Table of C o n t e n t s: + + 1. Introduction.....................|crvdoc-intro| + 2. Installation.....................|crvdoc-install| + 3. Usage............................|crvdoc-usage| + 4. Customization....................|crvdoc-customization| + 5. Limitations & Bugs...............|crvdoc-limbugs| + + Appendix + + A GLOSSARY............................|crv-glossary| + B BIBLIOGRAPHY........................|crv-bibliography| + C COPYRIGHT & LICENSES................|crvdoc-copyright| + C.1 GNU General Public License........|crvdoc-licGPL| + C.2 GNU Free Documentation License....|crvdoc-licFDL| + C.3 GNU Lesser General Public License.|crvdoc-licLGPL| + C.4 Free Software Needs Free + Documentation.....................|crvdoc-licFreeDoc| + D AUTHOR..............................|crvdoc-author| + E CREDITS.............................|crvdoc-credits| + F HISTORY.............................|crvdoc-history| + + Go to |C-Reference| + + +Happy viming... + + +============================================================================== +1. INTRODUCTION *crvdoc-intro* + +The intention of this project is to provide a C-reference manual that can +be accessed from within Vim. + +This project consists of four parts: + 1. crefvim.vim plugin to get access to the C-reference + 2. crefvimdoc.txt documentation of this project + 3. crefvim.txt a C-reference with Vim-tags for navigation + 4. help.vim an extention to the standard syntax highlighting for + help files (needed and active only for the C-reference + manual) + +The C-reference is a reference, it is NOT a tutorial or a guide on how +to write C-programs. It is a quick reference to the functions and syntax +of the standard C language. + +The project CRefVim is released under the GNU General Public License 2 +(GPL 2) or later. +The documents of the project CRefVim are released under the GNU Free +Documentation License (GNU FDL) version 1.1 or later. +For further information on licenses see |crvdoc-copyright|. + + + +============================================================================== +2. INSTALLATION *crvdoc-install* + +CRefVim consists of four files, the script 'crefvim.vim', its +documentation 'crefvimdoc.txt', the C-reference 'crefvim.txt' and a syntax +file to extend the standard syntax highlighting for help files called +'help.vim'. + +To use the script copy it into your local plugin-directory + Unix: ~/.vim/plugin + Windows: c:\vimfiles\plugin +After starting Vim this script is sourced from their automatically. + +This script can be customized in your .vimrc, for further information +see |crvdoc-customization|. + + +You have to add this documentation and the C-reference to Vim's help +system. To do this, copy both 'crefvimdoc.txt' and 'crefvim.txt' to +your local doc-directory: + Unix: ~/.vim/doc + Windows: c:\vimfiles\doc + +Then start Vim and do: + :helptags ~/.vim/doc (or :helptags c:\vimfiles\doc for Windows) + + +Finally the standard help syntax highlighting must be extended, so that +the C-reference is viewed correctly. To do so, copy the file 'help.vim' to +your local after/syntax directory: + Unix: ~/.vim/after/syntax + Windows: c:\vimfiles\after\syntax + +This extention of the help syntax file is only active for the C-reference +manual. + + +That's all to do. + + +General Hint: If the console version of Vim is used, the background color + of Vim and the background color of the console should be the + same. If so, the control characters used in help-files to do + some syntax-highlighting are not visible. + + + +============================================================================== +3. USAGE *crvdoc-usage* + +There are several ways to specify a word CRefVim should search for in order +to view help: + + <Leader>cr normal mode: get help for word under cursor + Memory aid cr: (c)-(r)eference + <Leader>cr visual mode: get help for visually selected text + Memory aid cr: (c)-(r)eference + <Leader>cw: prompt for word CRefVim should search for + Memory aid cw: (c)-reference (w)hat + <Leader>cc: jump to table of contents of the C-reference manual + Memory aid cc: (c)-reference (c)ontents + +Note: by default <Leader> is \, e.g. press \cr to invoke C-reference + +Note: The best way to search for an operator (++, --, %, ...) is to visually +select it and press <Leader>cr. + + + +============================================================================== +4. CUSTOMIZATION *crvdoc-customization* + +The key-maps used to invoke CRefVim can be customized. To do so set the +following variables in your .vimrc-file. If they are not set, defaults are +taken. + + - <Plug>CRV_CRefVimVisual + mapping to start search for visually selected text + default: + vmap <silent> <unique> <Leader>cr <Plug>CRV_CRefVimVisual + + - <Plug>CRV_CRefVimNormal + mapping to start search for text under cursor + default: + nmap <silent> <unique> <Leader>cr <Plug>CRV_CRefVimNormal + + - <Plug>CRV_CRefVimAsk + mapping to ask for word to search for + default: + map <silent> <unique> <Leader>cw <Plug>CRV_CRefVimAsk + + - <Plug>CRV_CRefVimInvoke + mapping to let Vim jump to the contents of the C-reference manual + default: + map <silent> <unique> <Leader>cc <Plug>CRV_CRefVimInvoke + + + +============================================================================== +5. LIMITATIONS & BUGS *crvdoc-limbugs* + + +------------------------------------------------------------------------------ +5.1 Script *crvdoc-lbScript* + +Known limitations: + none + +Known bugs: + none - well, up to now ;-) + + +------------------------------------------------------------------------------ +5.2 C-Reference *crvdoc-lbCRef* + +Known incorrectnesses: + none + + + +============================================================================== +For Appendix A GLOSSARY go to |crv-glossary| + + + +============================================================================== +For Appendix B BIBLIOGRAPHY go to |crv-bibliography| + + + +============================================================================== +Appendix C COPYRIGHT & LICENSES *crvdoc-copyright* + + +CRefVim is copyright (c) 2002-2004 by Christian Habermann + +The scripts of the project CRefVim are released under the GNU General Public +License 2 (GPL 2) or later (see |crvdoc-licGPL| for license). + +The documents of the project CRefVim are released under the GNU Free +Documentation License (GNU FDL) version 1.1 or later (see |crvdoc-licFDL| for +license). + +The most sections about the standard C library functions, macros and types +were extracted from "The GNU C Library Reference Manual", edition 0.10. +"The GNU C Library Reference Manual" is copyright (c) 1993 - 2002 by the +Free Software Foundation, Inc. + + + + +Scripts of the project CRefVim: +------------------------------- +Copyright (c) 2002-2004 by Christian Habermann. + + +All scripts of CRefVim are an entity called "program": + + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2 of the License, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warrenty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + +Documents of the project CRefVim: +--------------------------------- +Copyright (c) 2002-2004 by Christian Habermann. + + +This file and the C-reference manual is an entity called "document": + + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.1 or +any later version published by the Free Software Foundation; with the +Invariant Sections being "Free Software Needs Free Documentation" and +"GNU Lesser General Public License", the Front-Cover text being +"A Manual Supported by GNU", and with the Back-Cover text being +"You have freedom to copy and modify this manual.". +A copy of the license is included in the section entitled +"GNU Free Documentation License". + + + +------------------------------------------------------------------------------ +Appendix C.1 GNU General Public License *crvdoc-licGPL* + + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + + + +------------------------------------------------------------------------------ +Appendix C.2 GNU Free Documentation License *crvdoc-licFDL* + + + GNU Free Documentation License + Version 1.1, March 2000 + + Copyright (C) 2000 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + +0. PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +written document "free" in the sense of freedom: to assure everyone +the effective freedom to copy and redistribute it, with or without +modifying it, either commercially or noncommercially. Secondarily, +this License preserves for the author and publisher a way to get +credit for their work, while not being considered responsible for +modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + + +1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work that contains a +notice placed by the copyright holder saying it can be distributed +under the terms of this License. The "Document", below, refers to any +such manual or work. Any member of the public is a licensee, and is +addressed as "you". + +A "Modified Version" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall subject +(or to related matters) and contains nothing that could fall directly +within that overall subject. (For example, if the Document is in part a +textbook of mathematics, a Secondary Section may not explain any +mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, whose contents can be viewed and edited directly and +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup has been designed to thwart or discourage +subsequent modification by readers is not Transparent. A copy that is +not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML designed for human modification. Opaque formats include +PostScript, PDF, proprietary formats that can be read and edited only +by proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML produced by some word processors for output +purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + + +2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + + +3. COPYING IN QUANTITY + +If you publish printed copies of the Document numbering more than 100, +and the Document's license notice requires Cover Texts, you must enclose +the copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a publicly-accessible computer-network location containing a complete +Transparent copy of the Document, free of added material, which the +general network-using public has access to download anonymously at no +charge using public-standard network protocols. If you use the latter +option, you must take reasonably prudent steps, when you begin +distribution of Opaque copies in quantity, to ensure that this +Transparent copy will remain thus accessible at the stated location +until at least one year after the last time you distribute an Opaque +copy (directly or through your agents or retailers) of that edition to +the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + + +4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +A. Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. +B. List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has less than five). +C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. +D. Preserve all the copyright notices of the Document. +E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. +F. Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. +G. Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. +H. Include an unaltered copy of this License. +I. Preserve the section entitled "History", and its title, and add to + it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section entitled "History" in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. +J. Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the "History" section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. +K. In any section entitled "Acknowledgements" or "Dedications", + preserve the section's title, and preserve in the section all the + substance and tone of each of the contributor acknowledgements + and/or dedications given therein. +L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. +M. Delete any section entitled "Endorsements". Such a section + may not be included in the Modified Version. +N. Do not retitle any existing section as "Endorsements" + or to conflict in title with any Invariant Section. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties--for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + + +5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections entitled "History" +in the various original documents, forming one section entitled +"History"; likewise combine any sections entitled "Acknowledgements", +and any sections entitled "Dedications". You must delete all sections +entitled "Endorsements." + + +6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + + +7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, does not as a whole count as a Modified Version +of the Document, provided no compilation copyright is claimed for the +compilation. Such a compilation is called an "aggregate", and this +License does not apply to the other self-contained works thus compiled +with the Document, on account of their being thus compiled, if they +are not themselves derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one quarter +of the entire aggregate, the Document's Cover Texts may be placed on +covers that surround only the Document within the aggregate. +Otherwise they must appear on covers around the whole aggregate. + + +8. TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License provided that you also include the +original English version of this License. In case of a disagreement +between the translation and the original English version of this +License, the original English version will prevail. + + +9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document except +as expressly provided for under this License. Any other attempt to +copy, modify, sublicense or distribute the Document is void, and will +automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + + +10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. + + +ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (c) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.1 + or any later version published by the Free Software Foundation; + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +If you have no Invariant Sections, write "with no Invariant Sections" +instead of saying which ones are invariant. If you have no +Front-Cover Texts, write "no Front-Cover Texts" instead of +"Front-Cover Texts being LIST"; likewise for Back-Cover Texts. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. + + + +------------------------------------------------------------------------------ +Appendix C.3 GNU Lesser General Public License *crvdoc-licLGPL* + + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + + +------------------------------------------------------------------------------ +Appendix C.4 Free Software Needs Free Documentation *crvdoc-licFreeDoc* + + +The biggest deficiency in the free software community today is not in the +software - it is the lack of good free documentation that we can include with +the free software. Many of our most important programs do not come with free +reference manuals and free introductory texts. Documentation is an essential +part of any software package; when an important free software package does not +come with a free manual and a free tutorial, that is a major gap. We have many +such gaps today. + +Consider Perl, for instance. The tutorial manuals that people normally use are +non-free. How did this come about? Because the authors of those manuals +published them with restrictive terms - no copying, no modification, source +files not available - which exclude them from the free software world. + +That wasn't the first time this sort of thing happened, and it was far from +the last. Many times we have heard a GNU user eagerly describe a manual that +he is writing, his intended contribution to the community, only to learn that +he had ruined everything by signing a publication contract to make it +non-free. + +Free documentation, like free software, is a matter of freedom, not price. The +problem with the non-free manual is not that publishers charge a price for +printed copies - that in itself is fine. (The Free Software Foundation sells +printed copies of manuals, too.) The problem is the restrictions on the use of +the manual. Free manuals are available in source code form, and give you +permission to copy and modify. Non-free manuals do not allow this. + +The criteria of freedom for a free manual are roughly the same as for free +software. Redistribution (including the normal kinds of commercial +redistribution) must be permitted, so that the manual can accompany every copy +of the program, both on-line and on paper. + +Permission for modification of the technical content is crucial too. When +people modify the software, adding or changing features, if they are +conscientious they will change the manual too - so they can provide accurate +and clear documentation for the modified program. A manual that leaves you no +choice but to write a new manual to document a changed version of the program +is not really available to our community. + +Some kinds of limits on the way modification is handled are acceptable. For +example, requirements to preserve the original author's copyright notice, the +distribution terms, or the list of authors, are ok. It is also no problem to +require modified versions to include notice that they were modified. Even +entire sections that may not be deleted or changed are acceptable, as long as +they deal with nontechnical topics (like this one). These kinds of +restrictions are acceptable because they don't obstruct the community's normal +use of the manual. + +However, it must be possible to modify all the technical content of the +manual, and then distribute the result in all the usual media, through all the +usual channels. Otherwise, the restrictions obstruct the use of the manual, it +is not free, and we need another manual to replace it. + +Please spread the word about this issue. Our community continues to lose +manuals to proprietary publishing. If we spread the word that free software +needs free reference manuals and free tutorials, perhaps the next person who +wants to contribute by writing documentation will realize, before it is too +late, that only free manuals contribute to the free software community. + +If you are writing documentation, please insist on publishing it under the +GNU Free Documentation License or another free documentation license. Remember +that this decision requires your approval - you don't have to let the +publisher decide. Some commercial publishers will use a free license if you +insist, but they will not propose the option; it is up to you to raise the +issue and say firmly that this is what you want. If the publisher you are +dealing with refuses, please try other publishers. If you're not sure whether +a proposed license is free, write to licensing@gnu.org. + +You can encourage commercial publishers to sell more free, copylefted manuals +and tutorials by buying them, and particularly by buying copies from the +publishers that paid for their writing or for major improvements. Meanwhile, +try to avoid buying non-free documentation at all. Check the distribution +terms of a manual before you buy it, and insist that whoever seeks your +business must respect your freedom. Check the history of the book, and try +reward the publishers that have paid or pay the authors to work on it. + +The Free Software Foundation maintains a list of free documentation published +by other publishers, at <http://www.fsf.org/doc/other-free-books.html>. + + + +============================================================================== +Appendix D AUTHOR *crvdoc-author* + +Author of CRefVim is Christian Habermann. For contact, write to: + + christian (at) habermann-net (point) de + + + +============================================================================== +Appendix E CREDITS *crvdoc-credits* + + +- Credit must go out to Bram Moolenaar and all the Vim developers for making + Vim to an excellent tool. + +- Credit must go out to the Free Software Foundation for specifying the + GNU Free Documentation License (GNU FDL) and for releasing "The GNU C + Library Reference Manual" under the GNU FDL. + "The GNU C Library Reference Manual" is copyright (c) 1993 - 2002 by the + Free Software Foundation, Inc. + +- Special thanks to Richard Stallman for helping me to release this + project in a way that is conform to the license of "The GNU C Library + Reference Manual". + He also gave permission to alter the Front-Cover text and the Back-Cover + text specified by the GNU FDL of "The GNU C Library Reference Manual" to: + Front-Cover text: "A Manual Supported by GNU" + Back-Cover text: "You have freedom to copy and modify this manual." + + (Original: + Front-Cover text: "A GNU Manual" + Back-Cover text: "You have freedom to copy and modify this GNU Manual, + like GNU software. Copies published by the Free + Software Foundation raise funds for GNU development." + ) + + + +============================================================================== +Appendix F HISTORY *crvdoc-history* + +Project CRefVim + + The most sections about the standard C library functions, macros and types + were extracted from "The GNU C Library Reference Manual", edition 0.10. + "The GNU C Library Reference Manual" is copyright (c) 1993 - 2002 by the + Free Software Foundation, Inc. + At http://www.gnu.org/manual/glibc-2.2.5/libc.html the original version + of this manual can be found. + + + - V 0.1.0 12. Dec. 2002 - 23. Feb. 2003 + initial version, no release + tested under Linux (vim, gvim 6.1) and Win98SE (gvim 6.1) + Consists of: + crefvim.vim V 0.1.0, initial version + crefvimdoc.txt V 0.1.0, initial version + crefvim.txt V 0.1.0, initial version + help.vim V 0.1.0, initial version + + + - V 0.2.0 5. Apr. 2003 + no release + tested under Linux (vim, gvim 6.1) and Win98SE (gvim 6.1) + Consists of: + crefvim.vim V 0.2.0 + - "Appendix D AUTHOR" added + crefvimdoc.txt V 0.2.0 + - "Appendix D AUTHOR" added + - License GNU FDL 1.1 instead of 1.2, since License is an invariant + section of the GNU manual. To avoid to include both 1.1 and 1.2, + I released the documents under 1.1. + - CREDITS extended + crefvim.txt V 0.1.0, not changed + help.vim V 0.1.0, not changed + + + - V 1.0.0 6. Apr. 2003 + no changes, first release + Consists of: + crefvim.vim V 1.0.0 + crefvimdoc.txt V 1.0.0 + crefvim.txt V 1.0.0 + help.vim V 1.0.0 + + + - V 1.0.1 13. Apr. 2003 + crefvimdoc.txt: + - bug-fix in description of installation: + destination of help.vim is after/syntax + Unix: ~/.vim/after/syntax + Windows: c:\vimfiles\after\syntax + (was syntax/after) + + Consists of: + crefvim.vim V 1.0.0 not changed + crefvimdoc.txt V 1.0.1 changed + crefvim.txt V 1.0.0 not changed + help.vim V 1.0.0 not changed + + + - V 1.0.2 15. Dec. 2003 + crefvimdoc.txt: some typos fixed + crefvim.txt: some typos fixed + + Consists of: + crefvim.vim V 1.0.0 not changed + crefvimdoc.txt V 1.0.2 changed + crefvim.txt V 1.0.1 changed + help.vim V 1.0.0 not changed + + + - V 1.0.3 4. Mar. 2004 + crefvimdoc.txt: copyright and version-numbers updated + + crefvim.txt: - marker for syntax-highlighting changed from 0xa7 to $ + in order to avoid problems with fonts that use + codes > 0x7f as multibyte characters (e.g. Chinese, + Korean, Japanese... fonts) + - two typos fixed + - three bad tags corrected + + help.vim: syntax-highlighting adapted to new marker + + Consists of: + crefvim.vim V 1.0.0 not changed + crefvimdoc.txt V 1.0.3 changed + crefvim.txt V 1.0.2 changed + help.vim V 1.0.1 changed + + + - V 1.0.4 27. Nov. 2004 + crefvimdoc.txt: history and version numbers updated + + crefvim.txt: - I.5.13.2: example on how to assign an absolute address + to a function pointer added + - I.5.12: hint on volatile added + - dead tag corrected + + Consists of: + crefvim.vim V 1.0.0 not changed + crefvimdoc.txt V 1.0.4 changed + crefvim.txt V 1.0.3 changed + help.vim V 1.0.1 not changed + + + +------------------------------------------------------------------------------ + vim:tw=78:ts=4:ft=help:norl: diff --git a/.vim/doc/csupport.txt b/.vim/doc/csupport.txt new file mode 100644 index 0000000..615279e --- /dev/null +++ b/.vim/doc/csupport.txt @@ -0,0 +1,2152 @@ +*csupport.txt* C/C++ Support February 05 2010 + +C/C++ Support *c-support* *csupport* + Plugin version 5.10 + for Vim version 7.0 and above + Fritz Mehner <mehner@fh-swf.de> + +C/C++-IDE for Vim/gVim. It is written to considerably speed up writing code in +a consistent style. This is done by inserting complete statements,idioms, +code snippets, templates, and comments. Syntax checking, compiling, running +a program, running a code checker or a reformatter can be done with a +keystroke. + + 1. Usage |csupport-usage-gvim| + 1.1 Menu 'Comments' |csupport-comm| + 1.1.1 Append aligned comments |csupport-comm-aligned| + 1.1.2 Adjust end-of-line comments |csupport-comm-realign| + 1.1.3 Code to comment |csupport-code-to-comm| + 1.1.4 Comment to code |csupport-comm-to-code| + 1.1.5 Frame comments, file header, ... |csupport-comm-frame| + 1.1.6 File section comments .. |csupport-comm-sections| + 1.1.7 Keyword comment, special comment |csupport-comm-keyword| + 1.1.8 Tags (plugin) |csupport-comm-tags| + 1.1.9 Date and date+time |csupport-comm-date| + 1.1.10 C to C++ comments and vice versa |csupport-comm-c-cpp| + 1.2 Menu 'Statements' |csupport-stat| + 1.2.1 Normal mode, insert mode. |csupport-stat-normal-mode| + 1.2.2 Visual mode. |csupport-stat-visual-mode| + 1.3 Menu 'Preprocessor' |csupport-prep| + 1.3.1 Normal mode, insert mode. |csupport-prep-normal-mode| + 1.3.2 Visual mode. |csupport-prep-visual-mode| + 1.3.3 Block out code with #if 0 .. #endif |csupport-prep-if0| + 1.3.4 Ex-commands |csupport-prep-ex| + 1.4 Menu 'Idioms' |csupport-idioms| + 1.4.1 Item 'function' |csupport-idioms-function| + 1.4.2 for-loop control |csupport-idioms-for-loop| + 1.4.3 Item 'open input file' |csupport-idioms-input| + 1.4.4 Item 'open output file' |csupport-idioms-output| + 1.5 Menu 'Snippets' |csupport-snippets| + 1.5.1 Code snippets |csupport-snippets| + 1.5.2 Picking up prototypes |csupport-proto| + 1.5.3 Code templates |csupport-templates-menu| + 1.6 Menu 'C++' |csupport-c++| + 1.6.1 Normal mode, insert mode. |csupport-c++-normal-mode| + 1.6.2 Visual mode. |csupport-c++-visual-mode| + 1.6.3 Method implementation |csupport-c++-method-impl| + 1.6.4 Ex commands |csupport-c++-ex| + 1.7 Menu 'Run' |csupport-run| + 1.7.1 Minimal make functionality |csupport-run-buffer| + 1.7.2 Command line arguments |csupport-run-cmdline-args| + 1.7.3 Run make |csupport-run-make| + 1.7.4 Command line arguments for make |csupport-run-make-args| + 1.7.5 Splint |csupport-run-splint| + 1.7.6 CodeCheck |csupport-run-codecheck| + 1.7.7 Indent |csupport-run-indent| + 1.7.8 Hardcopy |csupport-run-hardcopy| + 1.7.9 Rebuild templates |csupport-run-templates| + 1.7.10 Xterm size |csupport-run-xterm| + 1.7.11 Output redirection |csupport-run-output| + 1.8 Help |csupport-help| + + 2. Usage without GUI |csupport-usage-vim| + 3. Hotkeys |csupport-hotkeys| + 4. Customization and configuration |csupport-custom| + 4.1 Global variables |csupport-custom-glob-vars| + 4.2 The root menu |csupport-custom-root-menu| + 4.3 System-wide installation |csupport-system-wide| + 5. Template files and tags |csupport-templates| + 5.1 Template files |csupport-templates-files| + 5.2 Macros |csupport-templates-macros| + 5.2.1 User defined formats for date and time |csupport-templates-date| + 5.3 Templates |csupport-templates-names| + 5.3.1 Template names |csupport-templates-names| + 5.3.2 Template definition |csupport-templates-definition| + 5.3.3 Template expansion |csupport-templates-expansion| + 5.3.4 The macros <+text+> etc. |csupport-templates-jump| + 5.3.5 Command Ctrl-j |csupport-Ctrl-j| + 5.4 Switching between template sets |csupport-templates-sets| + 5.5 Binding a style to a file extension |csupport-templates-bind| + 6. C/C++ Dictionaries |csupport-dictionary| + 7. Extend ctags |csupport-ctags| + 7.1 Make and qmake |csupport-ctags-make| + 7.2 Templates |csupport-ctags-templates| + 8. Folding |csupport-folding| + 9 Additional Mappings |csupport-ad-mappings| + 10. Windows particularities |csupport-windows| + 11. Additional tips |csupport-tips| + 12. Troubleshooting |csupport-troubleshooting| + 13. Release Notes /Change Log |csupport-release-notes| + + How to add this help file to Vim's help |add-local-help| + + +============================================================================== +1. USAGE WITH GUI (gVim) *csupport-usage-gvim* +============================================================================== + +If the root menu 'C/C++' is not visible call it with the item "Load C Support" +from the standard Tools-menu. +The item "Load C Support" can also be used to unload the C/C++-root menu. + +Nearly all menu entries insert code snippets or comments. All these stuff is +taken from template files and can be changed by the user to meet his +requirements (see|csupport-templates|). + +------------------------------------------------------------------------------ +1.1 MENU 'Comments' *csupport-comm* +------------------------------------------------------------------------------ + +1.1.1 APPEND ALIGNED COMMENTS TO CONSECUTIVE LINES *csupport-comm-aligned* + +In NORMAL MODE the menu items 'end-of-line comment' will append an comment to +the current line. +In VISUAL MODE these item will append aligned comments to all marked lines. +Marking the first 4 lines + + print_double_array ( double array[], + int n, + int columns, + char* arrayname + ) + +and choosing 'end-of-line com. /**/' will yield. + + print_double_array ( double array[], /* */ + int n, /* */ + int columns, /* */ + char* arrayname /* */ + ) /* */ + +If one ore more lines go beyond the starting column (s.below) the comments +will start at the 2. column after the longest line. The cursor will be +positioned inside the first comment. + +The default starting column is 49 ( = (multiple of 2,4, or 8) + 1 ). This can +be changed by setting a global variable in the file ~/.vimrc , e.g. : + + let g:C_LineEndCommColDefault = 45 + +The starting column can also be set by the menu item +'Comments->set end-of-line com. col' . Just position the cursor in an +arbitrary column (column number is shown in the Vim status line) and choose +this menu item. This setting is buffer related. + +If the cursor was at the end of a line you will be asked for a column number +because this position is most likely not the desired starting column. +Your choice will be confirmed. + +------------------------------------------------------------------------------ + +1.1.2 ADJUST END-OF-LINE COMMENTS *csupport-comm-realign* + +After some changes end-of-line comments may be no longer aligned: + + print_double_array ( double array[], /* */ + long int n, /* */ + unsigned int columns, /* */ + char* a_name /* */ + ) /* */ + +Realignment can be achieved with the menu item 'adjust end-of-line com.' In +normal mode the comment (if any) in the current line will be aligned to the +end-of-line comment column (see above) if possible. In visual mode the +comments in the marked block will be aligned: + + print_double_array ( double array[], /* */ + long int n, /* */ + unsigned int columns, /* */ + char* a_name /* */ + ) /* */ + +The realignment will not be done for comments with nothing else than leading +whitespaces. These comments are usually captions: + + max = other.max; /* the maximum value */ + len = other.len; /* the length */ + /* ===== the next section ===== */ + pos = (x+y+z)/3.0; /* the next position */ + +After the alignment we have: + + max = other.max; /* the maximum value */ + len = other.len; /* the length */ + /* ===== the next section ===== */ + pos = (x+y+z)/3.0; /* the next position */ + +------------------------------------------------------------------------------ + +1.1.3 CODE TO COMMENT *csupport-code-to-comm* + +The marked block + +xxxxxxxx +xxxxxxxx +xxxxxxxx + +will be changed by the menu item 'code->comment /**/' into the multiline +comment (all (partially) marked lines): + +/* xxxxxxxx + * xxxxxxxx + * xxxxxxxx + */ + +The marked block will be changed by the menu item 'code->comment //' into the +multiline comment + +//xxxxxxxx +//xxxxxxxx +//xxxxxxxx + +The menu items works also for a single line. A single line needs not to be +marked. + +------------------------------------------------------------------------------ + +1.1.4 COMMENT TO CODE *csupport-comm-to-code* + +If one (or more) complete comment (i.e. all lines belonging to the comment) is +marked the item 'comment->code' will uncomment it. If the following lines +are marked + + * printf ("\n"); + */ + + printf ("\n"); + + // printf ("\n"); + // + + /* + * printf ("\n"); + */ + +uncommenting will yield + + * printf ("\n"); + */ + + printf ("\n"); + + printf ("\n"); + + + + printf ("\n"); + +The first 2 lines are only a part of a C-comment and remain unchanged. +A C-comment can start with /* , /** or /*! . + +The menu item works also for a single line with a leading // . A single line +needs not to be marked. + +------------------------------------------------------------------------------ + +1.1.5 FRAME COMMENTS, FILE HEADER, ... *csupport-comm-frame* + +Frame comments, file header comments and function, methods, class descriptions +are read as templates from the appropriate files (see |csupport-templates|). + +There are to file description templates (menu items 'file description (impl.)' +and 'file description (header)', see also |csupport-templates|): + + comment.file-description : files *.c *.cc *.cp *.cxx *.cpp *.CPP *.c++ + *.C *.i *.ii + + comment.file-description-header : everything else with filetype 'c' or 'cpp' + +The appropriate template will also be included into a new file. The plugin +decides on the basis of the file extension. The default is shown above. You +can change the list by setting a global variable in '~/.vimrc': + + au BufRead,BufNewFile *.XYZ set filetype=c + + let g:C_SourceCodeExtensions = 'XYZ c cc cp cxx cpp CPP c++ C i ii' + +A new file named 'test.XYZ' will now be considered a C implementation file. + +------------------------------------------------------------------------------ + +1.1.6 FILE SECTION COMMENTS *csupport-comm-sections* + +File section comments can be uses to separate typical C- and H-file sections +with comments of similar appearance, e.g. + +/* ##### HEADER FILE INCLUDES ################################################### */ + +/* ##### MACROS - LOCAL TO THIS SOURCE FILE ################################### */ + +/* ##### TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE ######################### */ + +These section comments can also be inserted using the hotkey \ccs for C/C++ +files, or \chs for H-files. These hotkeys will start the command +'CFileSection' or 'HFileSection' on the command line: + + :CFileSection + :HFileSection + +Now type a <Tab> to start the selection menu to choose from. + +------------------------------------------------------------------------------ + +1.1.7 KEYWORD COMMENT, SPECIAL COMMENT *csupport-comm-keyword* + +Keword comments are end-of-line comments: + + /* :<keyword>:<date+time>:<author reference>: <arbitrary comment text> */ + +Keywords are + + BUG COMPILER TODO TRICKY WARNING WORKAROUND user-defined-keyword + +These are preliminary comments to document places where works will be resumed +shortly. They are usually not meant for the final documentation. These +comments are easily found by searching for the keyword. +The keyword comments can also be inserted using the hotkey \ckc . This hotkey +starts the command 'KeywordComment' on the command line: + + :KeywordComment + +Now type a <Tab> to start the selection menu to choose from. + +Special comments are occasionally used to mark special features of a code +construct (e.g. a fall through cases in a switch statement, an empty loop): + + /* EMPTY */ + /* NOT REACHED */ + /* REMAINS TO BE IMPLEMENTED */ + .... + +The special comments can also be inserted using the hotkey \csc . This hotkey +starts the command 'SpecialComment' on the command line: + + :SpecialComment + +Now type a <Tab> to start the selection menu to choose from. + +------------------------------------------------------------------------------ + +1.1.8 TAGS (PLUGIN) *csupport-comm-tags* + +The submenu 'tags (plugin)' let you insert the predefined macros from the +template system (see|csupport-templates-macros|). In visual mode the marked +string will be replaced by the macro. + +------------------------------------------------------------------------------ + +1.1.9 DATE AND DATE+TIME *csupport-comm-date* + +The format for 'date' and 'date time' can be defined by the user (see +|csupport-templates-date|). In visual mode the marked string will be replaced +by the macro (e.g. to update date and time). + +------------------------------------------------------------------------------ + +1.1.10 C TO C++ COMMENTS AND VICE VERSA *csupport-comm-c-cpp* + +The menu item '// xxx -> /* xxx */' changes a C++ comment into an C comment. +This is done for the current line in normal or insert mode and for a marked +area of lines in visual mode. +If there are multiple C comments only the first one will be changed: + printf ("\n"); /* one */ /* two */ /* three */ +will be changed into + printf ("\n"); // one /* two */ /* three */ + +The menu item '/* xxx */ -> // xxx' changes a C comment into an C++ comment. + +------------------------------------------------------------------------------ +1.2 MENU 'Statements' *csupport-stat* +------------------------------------------------------------------------------ + +1.2.1 NORMAL MODE, INSERT MODE. *csupport-stat-normal-mode* + +An empty statement will be inserted and properly indented. The item 'if{}' +will insert an if-statement: + +if ( ) +{ +} + + +1.2.2 VISUAL MODE. *csupport-stat-visual-mode* + +STATEMENTS WITH BLOCKS AND CASE LABEL. +-------------------------------------- +The highlighted area + +xxxxx +xxxxx + +can be surrounded by one of the following statements: + + +----------------------------+-----------------------------+ + | if ( ) | if ( ) | + | { | { | + | xxxxx | xxxxx | + | xxxxx | xxxxx | + | } | } | + | | else | + | | { | + | | } | + +----------------------------+-----------------------------+ + | for ( ; ; ) | while ( ) | + | { | { | + | xxxxx | xxxxx | + | xxxxx | xxxxx | + | } | } | + +----------------------------+-----------------------------+ + | do | | + | { | { | + | xxxxx | xxxxx | + | xxxxx | xxxxx | + | } | } | + | while ( ); | | + +----------------------------+-----------------------------+ + | switch ( ) { | + | case : | + | break; | + | | + | case : | + | break; | + | | + | case : | + | break; | + | | + | case : | + | break; | + | | + | default: | + | break; | + | } | + +----------------------------+-----------------------------+ + +The whole statement will be indented after insertion. + + +STATEMENTS WITHOUT BLOCKS. +-------------------------- +One of the following statements can be inserted: + + +-------------------------------+--------------------------+ + | if ( ) | for ( ; ; ) | + +-------------------------------+--------------------------+ + | if ( ) | while ( ) | + | else | | + +-------------------------------+--------------------------+ + | case : | | + | break; | | + +-------------------------------+--------------------------+ + + +------------------------------------------------------------------------------ +1.3 MENU 'Preprocessor' *csupport-prep* +------------------------------------------------------------------------------ + +1.3.1 NORMAL MODE, INSERT MODE. *csupport-prep-normal-mode* + +The preprocessor statements will be inserted and properly indented. + +1.3.2 VISUAL MODE. *csupport-prep-visual-mode* + +STATEMENTS WITH BLOCKS +---------------------- +The highlighted area + +xxxxx +xxxxx + +can be surrounded by one of the following statements: + + +----------------------------+-----------------------------+ + | #if CONDITION | + | xxxxx | + | xxxxx | + | #else /* ----- #if CONDITION ----- */ | + | | + | #endif /* ----- #if CONDITION ----- */ | + +----------------------------------------------------------+ + | #ifdef CONDITION | + | xxxxx | + | xxxxx | + | #else /* ----- #ifdef CONDITION ----- */ | + | | + | #endif /* ----- #ifdef CONDITION ----- */ | + +----------------------------------------------------------+ + | #ifndef CONDITION | + | xxxxx | + | xxxxx | + | #else /* ----- #ifndef CONDITION ----- */ | + | | + | #endif /* ----- #ifndef CONDITION ----- */ | + +----------------------------------------------------------+ + | #ifndef INC_TEST | + | #define INC_TEST | + | xxxxx | + | xxxxx | + | #endif /* ----- #ifndef INC_TEST ----- */ | + +----------------------------------------------------------+ + | #if 0 /* ----- #if 0 : If0Label_1 ----- */ | + | | + | #endif /* ----- #if 0 : If0Label_1 ----- */ | + +----------------------------------------------------------+ + +The macro name for an include guard (e.g. INC_TEST above) will be derived as a +suggestion from the file name. + +1.3.3 BLOCK OUT CODE WITH #if 0 ... #endif *csupport-prep-if0* + +The menu item #if 0 #endif inserts the lines + + #if 0 /* ----- #if 0 : If0Label_1 ----- */ + + #endif /* ----- #if 0 : If0Label_1 ----- */ + +In visual mode the marked block of lines will be surrounded by these lines. + +This is usually done to temporarily block out some code. The label names like +If0Label_1 are automatically inserted into the comments. The trailing numbers +are automatically incremented. These numbers can be changed by the user. The +next number will be one above the highest number found in the current buffer. + +A corresponding label can be found by searching with the vim star command (*). +All labels can be found with a global search like :g/If0Label_/ or +:g/If0Label_\d\+/. All corresponding lines can be deleted with :g/If0Label_/d . + + +REMOVE THE ENCLOSING #if 0 ... #endif -CONSTRUCT. + +The menu item 'remove #if #endif' removes such a construct if the cursor is +in the middle of such a section or on one of the two enclosing lines. Nested +constructs will be untouched. + +1.3.4 EX-COMMANDS *csupport-prep-ex* + +There are 4 additional Ex command which can be used to insert include +statements: + + Ex command hotkey includes + ------------------------------------------------------------------------- + :IncludeStdLibrary \ps C standard library + :IncludeC99Library \pc C99 library + :IncludeCppLibrary \+ps C++ standard library + :IncludeCppCLibrary \+pc C standard library ( #include <c...> ) + +Type :Inc<Tab> and choose one of the commands. Now type an additional space +and a <Tab> to show the whole list list or type a space and a few leading +characters to reduce this list. + +------------------------------------------------------------------------------ +1.4 MENU 'Idioms' *csupport-idioms* +------------------------------------------------------------------------------ + +1.4.1 Item 'function' *csupport-idioms-function* + +NORMAL MODE, INSERT MODE: +The name of the function is asked for and the following lines (for function +name "f") will be inserted: + + void + f ( ) + { + return ; + } /* ---------- end of function f ---------- */ + +VISUAL MODE: +Main or [static] function: the highlighted lines will go inside the new +function or main. +for-loops: the highlighted lines will be set in braces. + +1.4.2 for-loop control *csupport-idioms-for-loop* + +The menu items 'for( x=0; ... )' and 'for( x=n-1; ... )' can be used to write +the control statement for a for-loop counting upward or downward. These items +start an input dialog + + [TYPE (expand)] VARIABLE [START [END [INCR.]]] : + +asking for at least the name of the loop variable. The other parameters are +optional. The type is restricted to the following integral data types: + + char + int + long int + long + short int + short + size_t + unsigned char + unsigned int + unsigned long int + unsigned long + unsigned short int + unsigned short + unsigned + +One of these types can be specified by typing it completely or by typing zero +or more characters of its name and completing them to the full name by using +the tab key (tab completion). If the start of the type name is ambiguous (e.g. +'uns') a list of completion candidates is provided to choose from. + +1.4.3 Item 'open input file' *csupport-idioms-input* + +The item 'open input file' will create the statements to open and close an +input file (e.g. with the file pointer 'infile'). + +1.4.4 Item 'open output file' *csupport-idioms-output* + +The item 'open output file' will create the statements to open and close an +output file (e.g. with the file pointer 'outfile'). + +------------------------------------------------------------------------------ +1.5 MENU 'Snippets' *csupport-snippets* +------------------------------------------------------------------------------ + +1.5.1 CODE SNIPPETS + +Code snippets are pieces of code which are kept in separate files in a special +directory (e.g. a few lines of code or a complete template for a Makefile). +File names are used to identify the snippets. The snippet directory will be +created during the installation ( $HOME/.vim/codesnippets-c is the default). +Snippets are managed with the 3 items + + C/C++ -> Snippets -> read code snippet + C/C++ -> Snippets -> write code snippet + C/C++ -> Snippets -> edit code snippet + +from the Snippets submenu. + +CREATING A NEW SNIPPET +When nothing is marked, "write code snippet" will write the whole buffer +to a snippet file, otherwise the marked area will be written to a file. + +INSERT A SNIPPET +Select the appropriate file from the snippet directory ("read code snippet"). +The inserted lines will be indented. + +EDIT A SNIPPET +This is a normal edit. + +INDENTATION / NO INDENTATION +Code snippets are normally indented after insertion. To suppress indentation +add the file extension "ni" or "noindent" to the snippet file name, e.g. + + parameter_handling.c.noindent + +Snippet browser +--------------- +Under a GUI a file requester will be put up. Without GUI the filename will be +read from the command line. You can change this behavior by setting a global +variable in your ~/.vimrc : + + let g:C_GuiSnippetBrowser = 'commandline' + +The default value is 'gui'. + + +1.5.2 PICKING UP PROTOTYPES *csupport-proto* + +PICK UP PROTOTYPES. +To make a prototype from a function head mark the function head and choose +'Snippets -> pick up prototype'. From the first six lines of + + void + print_double_array ( double array[], /* array to print */ + int n, /* number of elements to print */ + int columns, /* number of elements per column */ + char* arrayname /* array name */ + ) + { + ... + } /* ---------- end of function print_double_array ---------- */ + +the prototype + + void print_double_array ( double array[], int n, int columns, char* arrayname ); + +is produced and put in an internal buffer. +- Leading and trailing whitespaces are removed. +- All inner whitespaces are squeezed. +- All comments will be discarded. +- Trailing parts of the function body (e.g a '{' ) will also be removed. +- The class name and the scope resolution operator will be removed (C++ method + implementations). +Further prototypes can be picked up and gathered in the buffer. + +For C++ methods namespace names and class names will be removed +(exception: 'std::' ). The first two lines of + + std::string + ROBOT::Robot::get_name ( void ) + { + return type_name; + } /* ----- end of method Robot::get_name ----- */ + +result in the prototype + + std::string get_name ( void ); + +Folding may help picking up prototypes (see |csupport-folding|). + + +INSERT PROTOTYPES +With 'Snippets -> insert prototype(s)' all picked up prototypes currently in +the buffer will be inserted below the cursor. +The prototype buffer will be cleared after insertion. + + +DISCARD PROTOTYPES +The prototype buffer can be cleared with 'Snippets -> clear prototype(s)' . + + +SHOW PROTOTYPES +The list of gathered prototypes can be shown with +'Snippets -> show prototype(s)'. The number and the filename are shown, e.g. + + (1) matrix.c # double** calloc_double_matrix ( int rows, int columns ); + (2) matrix.c # void free_double_matrix ( double **m ); + (3) foomain.c # void foo ( ); + + +REMARK. Generating prototypes this way is nice in a small project. You may +want to use an extractor like cextract or something else. + + +1.5.3 Code Templates *csupport-templates-menu* +--------------------- +Nearly all menu entries insert code snippets or comments. All these stuff is +taken from template files and can be changed by the user to meet his +requirements (see|csupport-templates|on how to use the template system). + +The menu item 'edit local templates' opens the main template file in a local +plugin installation. This is usually the file +'~/.vim/c-support/templates/Templates'. There may be dependent files +loaded from the main file. Now change whatever file you want, save it, and +click on the menu item 'reread templates' to read in the file(s) and to +rebuild the internal representation of the templates. + +The menu item 'edit global templates' opens the main template file in a +system-wide plugin installation (see |csupport-system-wide|). This is +usually the file '$VIM./vimfiles/c-support/templates/Templates'. + +Template browser +---------------- +Under a GUI a file requester will be put up. Without GUI the filename will be +read from the command line. You can change this behavior by setting a global +variable in your ~/.vimrc : + + let g:C_GuiTemplateBrowser = 'explorer' + +The default value is 'gui'. 'explorer' will start the file explorer +(see help|:Explore|). To use the commandline asign 'commandline'. + +------------------------------------------------------------------------------ +1.6 MENU 'C++' *csupport-c++* +------------------------------------------------------------------------------ + +1.6.1 NORMAL MODE, INSERT MODE. *csupport-c++-normal-mode* + +An empty statement will be inserted and in some cases properly indented. The +item 'try .. catch' will insert the following lines: + + try { + } + catch ( const &ExceptObj ) { // handle exception: + } + catch (...) { // handle exception: unspecified + } + +The cursor will go into the try block. + +1.6.2 VISUAL MODE. *csupport-c++-visual-mode* + +The highlighted area can be surrounded by one of the following statements: + + try - catch + catch + catch(...) + namespace { } + extern "C" { } + +The whole statement will be indented after insertion. + +1.6.3 METHOD IMPLEMENTATION *csupport-c++-method-impl* + +The menu item 'method implement.' asks for a method name. If this item is +called the first time you will see just an scope resolution operator. If you +specify the scope this is used the next time you call this item. If you use +one of the menu items to generate a class (see |csupport-templates|) the +scope will be extracted and used for the next method. + +1.6.4 EX COMMANDS *csupport-c++-ex* + +There are 4 additional Ex command which can be used to insert include +statements. Please see |csupport-prep-ex|. + +------------------------------------------------------------------------------ +1.7 MENU 'Run' *csupport-run* +------------------------------------------------------------------------------ + +1.7.1 MINIMAL MAKE FUNCTIONALITY *csupport-run-buffer* + +The 'Run' menu provides a minimal make functionality for single file projects +(e.g. in education) : + +SAVE AND COMPILE +'save and compile' saves the buffer and run the compiler with the given +options (see |csupport-custom-glob-vars|). + +An error window will be opened if the compiler reports errors and/or warnings. +Quickfix commands can now be used to jump to an error location. + +Consider using maps like + map <silent> <F7> <Esc>:cprevious<CR> + map <silent> <F8> <Esc>:cnext<CR> +in your ~/.vimrc file to jump over the error locations and make navigation +easier. The error list and the error locations in your source buffer will be +synchronized. + + +LINK +'link' makes an executable from the current buffer. If the buffer is not +saved, or no object is available or the object is older then the source step +'save and compile' is executed first. + +The behavior of the compiler / linker is determined by the options assigned to +the variables described in |csupport-custom-glob-vars| (4.group). + +RUN +'run' runs the executable with the same name (extension .e) as the current +buffer. If the buffer is not saved, or no executable is available or the +executable is older then the source steps 'save and compile' and 'link' are +executed first. + + +1.7.2 COMMAND LINE ARGUMENTS *csupport-run-cmdline-args* + +The item 'command line arguments' calls an input dialog which asks for command +line arguments. These arguments are forwarded to the program which is run by +the 'run' item. The arguments are kept until you change them. +For the first and only the first argument file name expansion will work (use +the Tab-key). Only the first string of the input can be expanded due to a +restriction of the Vim input function. To expand two or more filenames +specify them in reverse order: type the first characters of the last filename +and expand them. Go to the start of the input and type the beginning of the +last but one filename and expand it. + +The arguments belong to the current buffer (that is, each buffer can have its +own arguments). +If the buffer gets a new name with "save as" the arguments will now belong to +the buffer with the new name. + +The command line arguments can be followed by pipes and redirections: + + 11 22 | sort -rn | head -10 > out + +Caveat: If you look for the current arguments by calling this menu item again +be sure to leave it with a CR (not Esc !). Due to a limitation of an internal +Vim function CR will keep the arguments, Esc will discard them. + + +1.7.3 RUN make *csupport-run-make* + +The item 'make' runs the external make program. + + +1.7.4 COMMAND LINE ARGUMENTS FOR make *csupport-run-make-args* + +The item 'command line arguments for make' calls an input dialog which asks +for command line arguments for make. These arguments are forwarded to make +when called by the item 'make'. + + +1.7.5 SPLINT *csupport-run-splint* + +Splint is a tool for statically checking C programs (see http://www.splint.org). +Of course it has to be installed in order to be used within Vim. The menu +item 'Run->splint' will run the current buffer through splint. + +An error window will be opened if splint has something to complain about. +Quickfix commands can now be used to jump to an error location. For easier +navigation see tip under 'SAVE AND COMPILE' |csupport-run-buffer|. + +Splint has many options. Presumably the best way is to keep the options in an +option file (~/.splintrc). For a quick try you can use the menu item +'Run->cmd. line arg. for splint' to specify some buffer related options. + +When vim is started this plugin will check whether splint is executable. If +not, the menu item will *NOT' be visible. + + +1.7.6 CODECHECK *csupport-run-codecheck* + +CodeCheck (TM) is a commercial code analyzing tool produced by Abraxas +Software, Inc. (www.abraxas-software.com). +Of course it has to be installed in order to be used within Vim. The menu +item 'Run->CodeCheck' will run the current buffer through CodeCheck. + +An error window will be opened if CodeCheck has something to complain about. +Quickfix commands can now be used to jump to an error location. For easier +navigation see tip under 'SAVE AND COMPILE' |csupport-run-buffer|. + +CodeCheck has many options. For a quick try you can use the menu item +'Run->cmd. line arg. for CodeCheck' to specify some buffer related options. + +CodeCheck will be run with default options (see |csupport-custom-glob-vars|). +The default options can be overwritten by placing a global variable in +~/.vimrc , e.g. + + let g:C_CodeCheckOptions = "-K13 -Rmeyers" + +The default name for the executable is 'check'. There are other names in use +on different platforms. The name can be changed by placing a global variable +in ~/.vimrc , e.g. + + let g:C_CodeCheckExeName = "chknt.exe" + +When vim is started this plugin will check whether CodeCheck is executable. If +not, the menu item will *NOT' be visible. + + +1.7.7 INDENT *csupport-run-indent* + +The formatter 'indent' can be run over the whole buffer. Before formatting a +buffer this buffer will be saved to disk and you will be asked for a +confirmation. + +Indent has many options. These are kept in the file '.indent.pro' in your home +directory. See the indent manual for more information. + + +1.7.8 HARDCOPY *csupport-run-hardcopy* + +Generates a PostScript file from the whole buffer or from a marked region. +On a Windows system a printer dialog is displayed. +The hardcopy goes to the current working directory. If the buffer contains +documentation or other material from non-writable directories the hardcopy +goes to the HOME directory. The output destination will be shown in a message. + +The print header contains date and time for the current locale. The definition +used is + + let s:C_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" + +The current locale can be overwritten by changing the language, e.g. + + :language C + +or by setting a global variable in the file ~/.vimrc , e.g. : + + let g:C_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} SEITE %N" + +See :h printheader and :h strftime() for more details. + + +1.7.9 REBUILD TEMPLATES *csupport-run-templates* + +After editing one or more template files a click on this item rereads the +template files and rebuilds all templates. + + +1.7.10 XTERM SIZE *csupport-run-xterm* + +The size of the xterm used for running a program (below) can be set by this +menu item. The default is 80 columns with 24 lines. +This feature is not available under Windows. + + +1.7.11 OUTPUT REDIRECTION *csupport-run-output* + +Running a program can be done in one of three ways: +(1) Run the program from the gVim command line. + This is for interactive programs with little input and output. +(2) Run the program and direct the output into a window with name "C-Output". + The buffer and its content will disappear when the window is closed and + reused otherwise. + This is for non-interactive programs with little to very much output. + You have unlimited line length, regex search, navigation, ... + The tabstop value will be set to 8 for "C-Output". +(3) Run the program in an xterm. + +The output method can be chosen from the menu item 'Run->output: ...'. +This menu has three states: + + output: VIM->buffer->xterm + output: BUFFER->xterm->vim + output: XTERM->vim->buffer + +The first (uppercase) item shows the current method. The default is 'vim'. +This can be changed by setting the variable g:C_OutputGvim to another value. +Possible values are 'vim', 'buffer' and 'xterm' . + +The xterm defaults can be set in ~/.vimrc by the variable g:C_XtermDefaults . +The default is "-fa courier -fs 12 -geometry 80x24" : + font name : -fa courier + font size : -fs 12 + terminal size : -geometry 80x24 +See 'xterm -help' for more options. Xterms are not available under Windows. + +------------------------------------------------------------------------------ +1.8 'help' *csupport-help* +------------------------------------------------------------------------------ +Plugin help +----------- +The root menu item 'help (plugin)' shows this plugin help in a help window. +The help tags must have been generated with + :helptags ~/.vim/doc +The hotkey is \hp (for "help plugin"). + +Displaying a manual +------------------- +The root menu item 'show manual' shows the manual for the word under the +cursor. If there is more than one manual a selection list will be presented. +If there is no word under the cursor you can type in a name. An interface to +the on-line reference manuals must be installed (usually man(1) for +Linux/Unix, see|csupport-custom-glob-vars|). +The hotkey is \hm (for "help manual"). + +============================================================================== +2. USAGE WITHOUT GUI (Vim) *csupport-usage-vim* +============================================================================== + +The frequently used constructs can be inserted with key mappings. The +mappings are also described in the document c-hot-keys.pdf (reference card, +part of this package). +Hint: Typing speed matters. The combination of a leader ('\') and the +following character(s) will only be recognized for a short time. +The insert mode mappings start with ` (backtick). + +Legend: (i) insert mode, (n) normal mode, (v) visual mode + + -- Help --------------------------------------------------------------- + + \hm show manual for word under the cursor (n,i) + \hp show plugin help (n,i) + + -- Comments ----------------------------------------------------------- + + \cl end-of-line comment (n,v,i) + \cj adjust end-of-line comment(s) (n,v,i) + \cs set end-of-line comment column (n) + \c* code -> comment /* */ (n,v) + \cc code -> comment // (n,v) + \co comment -> code (n,v) + \cfr frame comment (n,i) + \cfu function comment (n,i) + \cme method description (n,i) + \ccl class description (n,i) + \cfdi file description (implementation) (n,i) + \cfdh file description (header) (n,i) + \ccs C/C++-file section (tab. compl.) (n,i) + \chs H-file section (tab. compl.) (n,i) + \ckc keyword comment (tab. compl.) (n,i) + \csc special comment (tab. compl.) (n,i) + \cd date (n,v,i) + \ct date \& time (n,v,i) + + -- Statements --------------------------------------------------------- + + \sd do { } while (n,v,i) + \sf for (n,i) + \sfo for { } (n,v,i) + \si if (n,i) + \sif if { } (n,v,i) + \sie if else (n,v,i) + \sife if { } else { } (n,v,i) + \se else { } (n,v,i) + \sw while (n,i) + \swh while { } (n,v,i) + \ss switch (n,v,i) + \sc case (n,i) + \s{ \sb { } (n,v,i) + + -- Preprocessor ------------------------------------------------------- + + \ps choose a standard library include (n,i) + \pc choose a C99 include (n,i) + \p< #include <> (n,i) + \p" #include "" (n,i) + \pd #define (n,i) + \pu #undef (n,i) + \pie #if #else #endif (n,v,i) + \pid #ifdef #else #endif (n,v,i) + \pin #ifndef #else #endif (n,v,i) + \pind #ifndef #def #endif (n,v,i) + \pi0 #if 0 #endif (n,v,i) + \pr0 remove #if 0 #endif (n,i) + \pe #error (n,i) + \pl #line (n,i) + \pp #pragma (n,i) + + -- Idioms ------------------------------------------------------------- + + \if function (n,v,i) + \isf static function (n,v,i) + \im main() (n,v,i) + \i0 for( x=0; x<n; x+=1 ) (n,v,i) + \in for( x=n-1; x>=0; x-=1 ) (n,v,i) + \ie enum + typedef (n,i) + \is struct + typedef (n,i) + \iu union + typedef (n,i) + \ip printf() (n,i) + \isc scanf() (n,i) + \ica p=calloc() (n,i) + \ima p=malloc() (n,i) + \isi sizeof() (n,v,i) + \ias assert() (n,v) + \ii open input file (n,i) + \io open output file (n,i) + + -- Snippets ----------------------------------------------------------- + + \nr read code snippet (n,i) + \nw write code snippet (n,v,i) + \ne edit code snippet (n,i) + \np pick up prototype (n,v,i) + \ni insert prototype(s) (n,i) + \nc clear prototype(s) (n,i) + \ns show prototype(s) (n,i) + \ntl edit local templates (n,i) + \ntg edit global templates (n,i) + \ntr rebuild templates (n,i) + + -- C++ ---------------------------------------------------------------- + + \+co cout << << endl; (n,i) + \+c class (n,i) + \+ps #include <...> STL (n,i) + \+pc #include <c..> C (n,i) + \+cn class (using new) (n,i) + \+ci class implementation (n,i) + \+cni class (using new) implementation (n,i) + \+mi method implementation (n,i) + \+ai accessor implementation (n,i) + + \+tc template class (n,i) + \+tcn template class (using new) (n,i) + \+tci template class implementation (n,i) + \+tcni template class (using new) impl. (n,i) + \+tmi template method implementation (n,i) + \+tai template accessor implementation (n,i) + + \+tf template function (n,i) + \+ec error class (n,i) + \+tr try ... catch (n,v,i) + \+ca catch (n,v,i) + \+c. catch(...) (n,v,i) + + -- Run ---------------------------------------------------------------- + + \rc save and compile (n,i) + \rl link (n,i) + \rr run (n,i) + \ra set comand line arguments (n,i) + \rm run make (n,i) + \rg cmd. line arg. for make (n,i) + \rp run splint (n,i) + \ri cmd. line arg. for splint (n,i) + \rk run CodeCheck (TM) (n,i) + \re cmd. line arg. for CodeCheck (TM) (n,i) + \rd run indent (n,v,i) + \rh hardcopy buffer (n,v,i) + \rs show plugin settings (n,i) + \rx set xterm size (n, only Linux/UNIX & GUI) + \ro change output destination (n,i) + + -- Load / Unload C/C++ Support ---------------------------------------- + + \lcs Load C/C++ Support Menus (n, GUI only) + \ucs Unload C/C++ Support Menus (n, GUI only) + +The hotkeys are defined in the file type plugin c.vim (part of this csupport +plugin package) and described in the document c-hot-keys.pdf + +Changing the default map leader '\' +----------------------------------- +The map leader can be changed by the user by setting a global variable in the +file .vimrc + + let g:C_MapLeader = ',' + +The map leader is now a comma. The 'line end comment' command is now defined +as ',cl'. This setting will be used as a so called local leader and influences +only files with filetype 'c' and 'cpp'. + +============================================================================== +3. HOTKEYS *csupport-hotkeys* +============================================================================== + +The following hotkeys are defined in normal, visual and insert mode: + + F9 compile and link + Alt-F9 write buffer and compile + Ctrl-F9 run executable + Shift-F9 set command line arguments + + Shift-F2 switch between source files and header files + +The hotkeys are defined in the file type plugin c.vim. All hotkeys from the +non-GUI mode also work for gVim (see |csupport-usage-vim|). + +Shift-F2 can be used to switch between source files and header files if the +plugin a.vim (http://vim.sourceforge.net/scripts/script.php?script_id=31) is +present. To suppress the creation of a new header file when switching from a +source file the file ~/.vimrc should contain a line + + let g:alternateNoDefaultAlternate = 1 + +A header file will only be opened if it already exists. + +The Shift-key is dead when you are working with Vim in a console terminal +(non-Gui). You could add + + noremap \a :A<CR> + inoremap \a <C-C>:A<CR> + +to get a hot key for this case. + +============================================================================== +4. CUSTOMIZATION *csupport-custom* +============================================================================== + +------------------------------------------------------------------------------ +4.1 GLOBAL VARIABLES *csupport-custom-glob-vars* +------------------------------------------------------------------------------ + +Several global variables are checked by the script to customize it: + + ---------------------------------------------------------------------------- + GLOBAL VARIABLE DEFAULT VALUE TAG (see below) + ---------------------------------------------------------------------------- + g:C_GlobalTemplateFile plugin_dir.'c-support/templates/Templates' + g:C_LocalTemplateFile $HOME.'/.vim/c-support/templates/Templates' + g:C_TemplateOverwrittenMsg 'yes' + g:C_Ctrl_j 'on' + + g:C_CodeSnippets plugin_dir."/c-support/codesnippets/" + g:C_Dictionary_File "" + g:C_LoadMenus "yes" + g:C_MenuHeader "yes" + g:C_OutputGvim "vim" + g:C_XtermDefaults "-fa courier -fs 12 -geometry 80x24" + g:C_Printheader "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" + g:C_MapLeader '\' + g:C_GuiSnippetBrowser 'gui' + g:C_GuiTemplateBrowser 'gui' + + Linux/UNIX: + g:C_ObjExtension ".o" + g:C_ExeExtension "" + g:C_CCompiler "gcc" + g:C_CplusCompiler "g++" + g:C_Man "man" + Windows: + g:C_ObjExtension ".obj" + g:C_ExeExtension ".exe" + g:C_CCompiler "gcc.exe" + g:C_CplusCompiler "g++.exe" + g:C_Man "man.exe" + g:C_CFlags "-Wall -g -O0 -c" + g:C_LFlags "-Wall -g -O0" + g:C_Libs "-lm" + g:C_LineEndCommColDefault 49 + g:C_CExtension "c" + g:C_TypeOfH "cpp" + g:C_SourceCodeExtensions "c cc cp cxx cpp CPP c++ C i ii" + + g:C_CodeCheckExeName "check" + g:C_CodeCheckOptions "-K13" + +The variable plugin_dir will automatically be set to one of the following values: + $HOME.'/.vim/' for Linux/Unix + $VIM.'/vimfiles/' for Windows + + ---------------------------------------------------------------------------- + + 1. group: g:C_GlobalTemplateFile : Sets the master template file (see|csupport-templates|) + g:C_LocalTemplateFile : Sets the local template file (see|csupport-templates|) + g:C_TemplateOverwrittenMsg : message if template is overwritten + g:C_Ctrl_j : hotkey Ctrl-j 'on'/'off' (see|csupport-Ctrl-j|) + + 2. group: g:C_CodeSnippets : The name of the code snippet directory + (see |csupport-snippets|). + g:C_Dictionary_File : The name(s) of the dictionary file(s) used for + word completion (see also |csupport-dictionary|) + g:C_Root : the name of the root menu of this plugin + g:C_LoadMenus : Load menus and mappings ("yes", "no") at startup. + g:C_MenuHeader : Switch the submenu header on/off. + g:C_OutputGvim : when program is running output goes to the vim + command line ("vim"), to a buffer ("buffer") or to + an xterm ("xterm"). + g:C_XtermDefaults : the xterm defaults + g:C_Printheader : hardcopy: definition of the page header + g:C_MapLeader : the map leader for hotkeys (see|csupport-usage-vim|) + g:C_GuiSnippetBrowser : code snippet browser: 'gui', 'commandline' + g:C_GuiTemplateBrowser : code template browser: 'gui', 'explorer', 'commandline' + + 3. group: g:C_CExtension : Extension of C files. Everything else is C++. + g:C_TypeOfH : filetype of header files with extension 'h' (c,cpp) + g:C_SourceCodeExtensions : filename extensions for C/C++ + implementation files + g:C_CCompiler : The name of the C compiler. + g:C_CplusCompiler : The name of the C++ compiler. + g:C_Man : The name of the man utility. + g:C_CFlags : Compiler flags used for a compilation. + g:C_LFlags : Compiler flags used for linkage. + g:C_Libs : Libraries to link with. + g:C_ObjExtension : C/C+ file extension for objects + (leading point required if not empty) + g:C_ExeExtension : C/C+ file extension for executables + (leading point required if not empty) + g:C_LineEndCommColDefault : Default starting column for end-of-line comments. + g:C_CodeCheckExeName : The name of the CodeCheck (TM) executable + (the default is 'check') + g:C_CodeCheckOptions : Default options for CodeCheck (TM) + (see |csupport-run-codecheck|). + +To override the default add appropriate assignments to ~/.vimrc . + +------------------------------------------------------------------------------ +4.2 THE ROOT MENU *csupport-custom-root-menu* +------------------------------------------------------------------------------ + +The variable g:C_Root, if set (in ~/.vimrc or in ~/.gvimrc), gives the name of +the single Vim root menu item in which the C/C++ submenus will be put. The +default is + '&C\/C\+\+.' +Note the terminating dot. A single root menu can be used if the screen is +limited or several plugins are used in parallel. + +If set to "", this single root menu item will not appear. Now all submenus +are put into the Vim root menu. This is nice for beginners in a lab +installation or for C-only programmers. + +------------------------------------------------------------------------------ +4.3 SYSTEM-WIDE INSTALLATION *csupport-system-wide* +------------------------------------------------------------------------------ + +A system-wide installation (one installation for all users) is done as +follows. + +As *** SUPERUSER *** : + +(1) Find the Vim installation directory. +The Vim Ex command ':echo $VIM' gives '/usr/local/share/vim' or something like +that. Beyond this directory you will find the Vim installation, e.g. in +'/usr/local/share/vim/vim71' if Vim version 7.1 has been installed. + +(2) Create a new subdirectory 'vimfiles', e.g. '/usr/local/share/vim/vimfiles'. + +(3) Install C/C++ Support +Copy the archive cvim.zip to this new directory and unpack it: + unzip cvim.zip + +(4) Generate the help tags: + :helptags $VIM/vimfiles/doc + + +As *** USER *** : + +Create your private snippet directory: + + mkdir --parents ~/.vim/c-support/codesnippets + +You may want to copy the snippets coming with this plugin (in +$VIM/vimfiles/c-support/codesnippets) into the new directory or to set a +link to the global directory. + +Create your private template directory: + + mkdir --parents ~/.vim/c-support/template + +Create a private template file 'Templates' in this directory to overwrite some +macros, e.g. + + *|AUTHOR|* = your name + *|AUTHORREF|* = ... + *|EMAIL|* = ... + *|COMPANY|* = ... + *|COPYRIGHT|* = ... + +You can also have local templates which overwrite the global ones. To suppress +the messages in this case set a global variable in '~/.vimrc' : + + let g:C_TemplateOverwrittenMsg= 'no' + +The default is 'yes'. + +============================================================================== +5. TEMPLATE FILES AND TAGS *csupport-templates* +============================================================================== + +------------------------------------------------------------------------------ +5.1 TEMPLATE FILES *csupport-templates-files* +------------------------------------------------------------------------------ + +Nearly all menu entries insert code snippets or comments. All these stuff is +taken from template files and can be changed by the user to meet his +requirements. + +The master template file is '$HOME/.vim/c-support/templates/Templates' for a +user installation and '$VIM/vimfiles/c-support/templates/Templates' for a +system-wide installation (see|csupport-system-wide|). + +The master template file starts with a macro section followed by templates for +single menu items or better by including other template files grouping the +templates according to the menu structure of this plugin. The master file +could look like this: + + $ + $ ============================================================= + $ ========== USER MACROS ====================================== + $ ============================================================= + $ + *|AUTHOR|* = Dr. Fritz Mehner + *|AUTHORREF|* = mn + *|EMAIL|* = mehner@fh-swf.de + *|COMPANY|* = FH Südwestfalen, Iserlohn + *|COPYRIGHT|* = Copyright (c)*|YEAR|,|AUTHOR|* + $ + $ ============================================================= + $ ========== FILE INCLUDES ==================================== + $ ============================================================= + $ + *|includefile|* = c.comments.template + *|includefile|* = c.cpp.template + *|includefile|* = c.idioms.template + *|includefile|* = c.preprocessor.template + *|includefile|* = c.statements.template + +Lines starting with a dollar sign are comments. The section starting +with *|AUTHOR|* assigns values to predefined tags +(see|csupport-templates-macros|) to personalize some templates. Other +predefined tags with given default values can be used (e.g. *|YEAR|* ). + +User defined tags are possible. They have the following syntax: + + *|macroname|* = replacement + +A macroname starts with a letter (uppercase or lowercase) followed by zero or +more letters, digits or underscores. + +------------------------------------------------------------------------------ +5.2 MACROS *csupport-templates-macros* +------------------------------------------------------------------------------ + +The following macro names are predefined. The first group is used to +personalize templates. + + ---------------------------------------------------------------------------- + PREDEFINED MACROS DEFAULT VALUE + ---------------------------------------------------------------------------- +*|AUTHOR|* "" +*|AUTHORREF|* "" +*|EMAIL|* "" +*|COMPANY|* "" +*|PROJECT|* "" +*|COPYRIGHTHOLDER|* "" +*|STYLE|* "" +*|includefile|* "" + +*|BASENAME|* filename without path and suffix +*|DATE|* the preferred date representation for the current locale + without the time +*|FILENAME|* filename without path +*|PATH|* path without filename +*|SUFFIX|* filename suffix +*|TIME|* the preferred time representation for the current locale + without the date and the time zone or name or abbreviation +*|YEAR|* the year as a decimal number including the century + +The macro *|includefile|* can be used to include an additional template file. +A file will be included only once. Commenting and uncommenting include macros +is a simple way to switch between several sets of templates (see also +|csupport-run-templates|). Overwriting existing macros and templates is +possible. + + ---------------------------------------------------------------------------- + PREDEFINED TAGS + ---------------------------------------------------------------------------- + <CURSOR> The cursor position after insertion of a template + <+text+>,<-text->, Jump targets in templates. Jump with Ctrl-j. + {+text+},{-text-} See |csupport-templates-jump|. + + <SPLIT> The split point when inserting in visual mode + (see|csupport-templates-definition|) + +A dependent template file can start with its own macro section. There is no +need to have all user defined macros in the master file. +When the first template definition is found (see below) macro definitions are +no longer recognized. + +------------------------------------------------------------------------------ +5.2.1 USER DEFINED FORMATS FOR DATE AND TIME *csupport-templates-date* +------------------------------------------------------------------------------ +The format for *|DATE|* ,*|TIME|* , and*|YEAR|* can be set by the user. The +defaults are + *|DATE|* '%x' + *|TIME|* '%X' + *|YEAR|* '%Y' +See the manual page of the C function strftime() for the format. The accepted +format depends on your system, thus this is not portable! The maximum length +of the result is 80 characters. + +User defined formats can be set using the following global variables in +~/.vimrc , e.g. + let g:C_FormatDate = '%D' + let g:C_FormatTime = '%H:%M' + let g:C_FormatYear = 'year %Y' + +------------------------------------------------------------------------------ +5.3 TEMPLATES *csupport-templates-names* +------------------------------------------------------------------------------ + +5.3.1 Template names + +The template behind a menu entry is identified by a given name. The first part +of the name identifies the menu, the second part identifies the item. The +modes are also hard coded (see|csupport-templates-definition|for the use of +<SPLIT>). + + TEMPLATE NAME MODES + -------------------------------------------------------------------------- + + comment.class normal + comment.end-of-line-comment normal + comment.file-description normal + comment.file-description-header normal + comment.file-section-cpp-class-defs normal + comment.file-section-cpp-class-implementations-exported normal + comment.file-section-cpp-class-implementations-local normal + comment.file-section-cpp-data-types normal + comment.file-section-cpp-function-defs-exported normal + comment.file-section-cpp-function-defs-local normal + comment.file-section-cpp-header-includes normal + comment.file-section-cpp-local-variables normal + comment.file-section-cpp-macros normal + comment.file-section-cpp-prototypes normal + comment.file-section-cpp-typedefs normal + comment.file-section-hpp-exported-class-defs normal + comment.file-section-hpp-exported-data-types normal + comment.file-section-hpp-exported-function-declarations normal + comment.file-section-hpp-exported-typedefs normal + comment.file-section-hpp-exported-variables normal + comment.file-section-hpp-header-includes normal + comment.file-section-hpp-macros normal + comment.frame normal + comment.function normal + comment.keyword-bug normal + comment.keyword-compiler normal + comment.keyword-keyword normal + comment.keyword-todo normal + comment.keyword-tricky normal + comment.keyword-warning normal + comment.keyword-workaround normal + comment.method normal + comment.special-constant-type-is-long normal + comment.special-constant-type-is-unsigned-long normal + comment.special-constant-type-is-unsigned normal + comment.special-empty normal + comment.special-fall-through normal + comment.special-implicit-type-conversion normal + comment.special-no-return normal + comment.special-not-reached normal + comment.special-remains-to-be-implemented normal + + cpp.accessor-implementation normal + cpp.catch normal, visual + cpp.catch-points normal, visual + cpp.cin normal + cpp.class-definition normal + cpp.class-implementation normal + cpp.class-using-new-definition normal + cpp.class-using-new-implementation normal + cpp.cout-operator normal + cpp.cout normal + cpp.error-class normal + cpp.extern normal, visual + cpp.method-implementation normal + cpp.namespace-block normal, visual + cpp.namespace normal + cpp.namespace-std normal + cpp.open-input-file normal + cpp.open-output-file normal + cpp.operator-in normal + cpp.operator-out normal + cpp.output-manipulator-boolalpha normal + cpp.output-manipulator-dec normal + cpp.output-manipulator-endl normal + cpp.output-manipulator-fixed normal + cpp.output-manipulator-flush normal + cpp.output-manipulator-hex normal + cpp.output-manipulator-internal normal + cpp.output-manipulator-left normal + cpp.output-manipulator-oct normal + cpp.output-manipulator-right normal + cpp.output-manipulator-scientific normal + cpp.output-manipulator-setbase normal + cpp.output-manipulator-setfill normal + cpp.output-manipulator-setiosflag normal + cpp.output-manipulator-setprecision normal + cpp.output-manipulator-setw normal + cpp.output-manipulator-showbase normal + cpp.output-manipulator-showpoint normal + cpp.output-manipulator-showpos normal + cpp.output-manipulator-uppercase normal + cpp.rtti-const-cast normal + cpp.rtti-dynamic-cast normal + cpp.rtti-reinterpret-cast normal + cpp.rtti-static-cast normal + cpp.rtti-typeid normal + cpp.template-accessor-implementation normal + cpp.template-class-definition normal + cpp.template-class-implementation normal + cpp.template-class-using-new-definition normal + cpp.template-class-using-new-implementation normal + cpp.template-function normal + cpp.template-method-implementation normal + cpp.try-catch normal, visual + + idioms.assert normal + idioms.calloc normal + idioms.enum normal, visual + idioms.fprintf normal + idioms.fscanf normal + idioms.function normal, visual + idioms.function-static normal, visual + idioms.main normal, visual + idioms.malloc normal + idioms.open-input-file normal + idioms.open-output-file normal + idioms.printf normal + idioms.scanf normal + idioms.sizeof normal + idioms.struct normal, visual + idioms.union normal, visual + + preprocessor.define normal + preprocessor.ifdef-else-endif normal, visual + preprocessor.if-else-endif normal, visual + preprocessor.ifndef-def-endif normal, visual + preprocessor.ifndef-else-endif normal, visual + preprocessor.include-global normal + preprocessor.include-local normal + preprocessor.undefine normal + + statements.block normal, visual + statements.case normal + statements.do-while normal, visual + statements.for-block normal + statements.for normal + statements.if-block-else normal, visual + statements.if-block normal, visual + statements.if-else normal, visual + statements.if normal + statements.switch normal, visual + statements.while-block normal, visual + statements.while normal + + +5.3.2 Template definition *csupport-templates-definition* + +A template definition starts with a template head line with the following +syntax: + + == templatename == [ position == ] + +The templatename is one of the above template identifiers. The position +attribute is optional. Possible attribute values are: + + above insert the template before the current line + append append the template to the current line + below insert the template below the current line + insert insert the template at the cursor position + start insert the template before the first line of the buffer + +An example: + + == comment.function == + /* + * === FUNCTION ======================================================= + * Name: <CURSOR> + * Description: + * ====================================================================== + */ + +The definition of a template ends at the next head line or at the end of the +file. + +Templates for the visual mode can use <SPLIT>. The text before <SPLIT> will +than be inserted above the marked area, the text after <SPLIT> will be +inserted behind the marked area. An example: + + == statements.if-block-else == + if ( <CURSOR> ) { + <SPLIT>} else { + } + +If applied to the marked block + + xxxxxxxxxxx + xxxxxxxxxxx + +this template yields + + if ( ) { + xxxxxxxxxxx + xxxxxxxxxxx + } else { + } + +The templates with a visual mode are shown in the table under +|csupport-templates-names|. + +5.3.3 Template expansion *csupport-templates-expansion* + +There are additional ways to control the expansion of a template. + +USER INPUT +---------- +If the usage of a yet undefined user macro starts with a question mark the +user will be asked for the replacement first, e.g. with the following template + + == idioms.function == + void<CURSOR> + *|?FUNCTION_NAME|* ( ) + { + <SPLIT> return ; + } /* ----- end of function*|FUNCTION_NAME|* ----- */ + +The user can specify the function name which then will be applied twice. If +the macro was already in use the old value will be suggested as default. + +MACRO MANIPULATION +------------------ + +A macro expansion can be controlled by the following attributes + + :l change macro text to lowercase + :u change macro text to uppercase + :c capitalize macro text + :L legalize name + +The include guard template is an example for the use of ':L' : + + == preprocessor.ifndef-def-endif == + #ifndef *|?BASENAME:L|_INC* + #define *|BASENAME|_INC* + <CURSOR><SPLIT> + #endif // ----- #ifndef*|BASENAME|_INC* ----- + +The base name of the file shall be used as part of the include guard name. +The predefined macro*|BASENAME|* is used to ask for this part because this +macro has already a defined value. That value can accepted or replaced by the +user. For the filename 'test test++test.h' the legalized base name +'TEST_TEST_TEST' will be suggested. + +Legalization means: + - replace all whitespaces by underscores + - replace all non-word characters by underscores + - replace '+' and '-' by underscore + +5.3.4 The macros <+text+> etc. *csupport-templates-jump* + +There are four macro types which can be used as jump targets in templates: + + <+text+> Can be jumped to by hitting Ctrl-j. + {+text+} Same as <+text+>. Used in cases where indentation gives unwanted + results with the first one. + + <-text-> Same as the two above. Will be removed if the template is used + {-text-} in visual mode. + +The text inside the brackets is userdefined and can be empty. The text +can be composed from letters (uppercase and lowercase), digits, underscores +and blanks. After the insertion of an template these jump targets will be +highlighted. + +5.3.5 Command Ctrl-j *csupport-Ctrl-j* + +Use the command Ctrl-j to jump to the next target. The target will be removed +and the mode will switched to insertion. Ctrl-j works in normal and in insert +mode. + +The template for a function can be written as follows: + + == idioms.function == + void<CURSOR> + |?FUNCTION_NAME| ( <+argument list+> ) + { + <SPLIT> return <+return value+>; + } /* ----- end of function |FUNCTION_NAME| ----- */ + +The cursor will be set behind 'void'. You can remove 'void' easily with +Ctrl-w (delete word before cursor) and insert a new type. A Ctrl-j leads you +to the argument list. The target disappears and you can type on. When the +function body is written a final Ctrl-j brings you to the return statement. + +The following example shows the usage of the type {-text-}. The idiom for the +opening of a file marks the line before the file is closed. This is also the +line where the template will be split to surround a marked area. In this case +(visual mode) the target is not needed and therefore removed (minus signs as +mnemonic). In normal and insert mode the target is meaningful and will be +therefore be present. The form <-...-> would result in a wrong indentation of +the file close statement. The brace type will be handled as a block and the +indentation will be correct. + + == cpp.open-input-file == + char *ifs_file_name = "<CURSOR>"; /* input file name */ + ifstream ifs; /* create ifstream object */ + + ifs.open (ifs_file_name); /* open ifstream */ + if (!ifs) { + cerr << "\nERROR : failed to open input file " << ifs_file_name << endl; + exit (EXIT_FAILURE); + } + <SPLIT>{-continue here-} + ifs.close (); /* close ifstream */ + +Extra feature of Ctrl-j +----------------------- +If none of the above described targets is left Ctrl-j can be used to jump +behind closing brackets, parenthesis, braces, or string terminators ('"`). +This feature is limited to the current line. Ctrl-j does not jump behind the +last character in a line. + + +How to switch the mapping for Ctrl-j off +---------------------------------------- +The original meaning of Ctrl-j is 'move [n] lines downward' (see |CTRL-j|). +If you are accustomed to use the deafult and don't like these jump targets you +can switch them off. Put the following line in the file .vimrc : + + let g:C_Ctrl_j = 'off' + +The default value of g:C_Ctrl_j is 'on'. You do not have to change the +template files. All jump targets will be removed before a template will be +inserted. + +============================================================================== +5.4 SWITCHING BETWEEN TEMPLATE SETS *csupport-templates-sets* +============================================================================== + +This plugin comes with two sets of templates. These are suggestions. You may +want to have additional sets for different projects or occasionally want to +use doxygen style comments. To facilitate switching use the macro*|STYLE|* +(|csupport-templates-files|) to define a unique name and the +IF-ENDIF-construct to choose a particular set of files for example: + + ... + + *|STYLE|* = C + $ + $ ============================================================= + $ ========== FILE INCLUDES ==================================== + $ ============================================================= + $ + == IF *|STYLE|* IS C == + $ + |includefile| = c.comments.template + |includefile| = c.cpp.template + |includefile| = c.idioms.template + |includefile| = c.preprocessor.template + |includefile| = c.statements.template + $ + == ENDIF == + + ... + +The syntax is as follows: + + == IF macro_name IS macro_value == + + == ENDIF == + +Includes outside an IF-ENDIF construct are associated with the default style +'default'. A style set does not have to a complete set of templates. For an +incomplete set the other templates are taken from the default style. + +IF, IS, and ENDIF are keywords. + +HINT. Use these constructs to avoid overwriting your templates when updating +csupport. Copy and rename the set of files you want to change and surround the +includes with an appropriate IF-construct: + + *|STYLE|* = MY_C + $ + ... + $ + == IF *|STYLE|* IS MY_C == + |includefile| = my_c.comments.template + |includefile| = my_c.cpp.template + |includefile| = my_c.idioms.template + |includefile| = my_c.preprocessor.template + |includefile| = my_c.statements.template + == ENDIF == + +Keep a copy of the main template file 'Templates' because this file will be +overwritten if you do not update manually. + +============================================================================== +5.5 BINDING A STYLE TO A FILE EXTENSION *csupport-templates-bind* +============================================================================== + +You can bind the existing styles to one or more filename extensions. To do so +assign a Dictionary to the global variable g:C_Styles in '~/.vimrc' : + +let g:C_Styles = { '*.c,*.h' : 'default', '*.cc,*.cpp,*.hh' : 'CPP' } + +A Dictionary is created with a comma separated list of entries in curly +braces. Each entry has a key and a value, separated by a colon. Each key can +only appear once. The keys are themselves a comma separated list of filename +pattern. The values are existing styles defined in the template files. +The given style will be set automatically when switching to a buffer or +opening a new buffer with the associated filename pattern and supersedes the +macro *|STYLE|* . + +============================================================================== +6. C/C++ DICTIONARY *csupport-dictionary* +============================================================================== + +The files + + c-c++-keywords.list + k+r.list + stl_index.list + +are a part of this plugin and can be used (together with your own lists) as +dictionaries for automatic word completion. This feature is enabled by +default. The default word lists are + + plugin_dir/c-support/wordlists/c-c++-keywords.list + plugin_dir/c-support/wordlists/k+r.list + plugin_dir/c-support/wordlists/stl_index.list + +The variable plugin_dir will automatically be set by the plugin to one of the +following values: + $HOME.'/.vim/' for Linux/Unix + $VIM.'/vimfiles/' for Windows +If you want to use an additional list MyC.list put the following lines into + ~/.vimrc : + + let g:C_Dictionary_File = PLUGIN_DIR.'/c-support/wordlists/c-c++-keywords.list,'. + \ PLUGIN_DIR.'/c-support/wordlists/k+r.list,'. + \ PLUGIN_DIR.'/c-support/wordlists/stl_index.list,'. + \ PLUGIN_DIR.'/c-support/wordlists/MyC.list' + +When in file ~/.vimrc the name PLUGIN_DIR has to be replaced by $HOME or +$VIM (see above). Whitespaces in the pathnames have to be escaped with a +backslash. +The right side is a comma separated list of files. Note the point at the end +of the first line (string concatenation) and the backslash in front of the +second line (continuation line). +You can use Vim's dictionary feature CTRL-X, CTRL-K (and CTRL-P, CTRL-N). + +============================================================================== +7. EXTENDING ctags *csupport-ctags* +============================================================================== + +------------------------------------------------------------------------------ +7.1 make AND qmake *csupport-ctags-make* +------------------------------------------------------------------------------ + +The use of the Vim plugin taglist.vim (Author: Yegappan Lakshmanan) is highly +recommended. It uses the program ctags which generates tag files for 3 dozen +languages (Exuberant Ctags, Darren Hiebert, http://ctags.sourceforge.net). +With the following extensions the list of targets in a makefile can be shown +in the taglist window. + + 1) Append the file customization.ctags to the file $HOME/.ctags . + + 2) Add the following lines (from customization.vimrc) to $HOME/.vimrc : + + " + "------------------------------------------------------------------- + " taglist.vim : toggle the taglist window + " taglist.vim : define the title texts for make + " taglist.vim : define the title texts for qmake + "------------------------------------------------------------------- + noremap <silent> <F11> <Esc><Esc>:Tlist<CR> + inoremap <silent> <F11> <Esc><Esc>:Tlist<CR> + + let tlist_make_settings = 'make;m:makros;t:targets;i:includes' + let tlist_qmake_settings = 'qmake;t:SystemVariables' + + if has("autocmd") + " ---------- qmake : set file type for *.pro ---------- + autocmd BufNewFile,BufRead *.pro set filetype=qmake + endif " has("autocmd") + + 3) restart vim/gvim + +The two maps will toggle the taglist window (hotkey F11) in all editing modes. +The two assignments define the headings for the (q)make sections in the +taglist window. The autocmd set the file type 'qmake' for the filename +extension 'pro' (ctags needs this). + +------------------------------------------------------------------------------ +7.2 TEMPLATES *csupport-ctags-templates* +------------------------------------------------------------------------------ + +If you frequently change the plugin templates and you are using the taglist +plugin (section above) you may want to use this plugin for navigation. This is +achieved in two steps. First add a new language definition to the file +$HOME/.ctags : + + --langdef=template + --langmap=template:.template,TEMPLATE + --regex-template=/^==\s+([^=]+)\s+==\s*(\s+==\s+([^=]+)\s+==)?/\1/t,template/ + +Now add the following lines to the file $HOME/.vimrc : + + let tlist_template_settings = 'template;t:template' + "--------------------------------------------------------------- + " plugin templates : set filetype for *.template + "--------------------------------------------------------------- + if has("autocmd") + autocmd BufNewFile,BufRead Templates set filetype=template + autocmd BufNewFile,BufRead *.template set filetype=template + endif " has("autocmd") + +The assignment defines the heading for the template section in the taglist +window. The autocmds set the file type 'template' for the main template file +'Templates' and the includefiles '*.template' (if any). + +============================================================================== +8. FOLDING *csupport-folding* +============================================================================== + +This plugin can be used together with folding. + +There are a few peculiarities when the cursor is on a closed fold before +inserting a template: + +Normal mode +----------- +Inserting blocks of complete lines below and above a fold (e.g. frame +comments) and inserting at the top of a buffer (e.g. file description) works +as usual. +Insertions which go to the end of a line (e.g. end-of-line comments) and +insertions which go to the cursor position (e.g. 'sizeof()') will be suppressed +and a warning will be shown. + +Visual mode +----------- +A range of lines containing closed folds can be surrounded by constructs which +have a visual mode, e.g. a for-loop: + + for ( ; ; ) { + +--- 4 lines: {------------------------------------------------------------ + } + +See |folding| for more information on folding. + +============================================================================== +9. Additional Mappings *csupport-ad-mappings* +============================================================================== + +There are a few additional filetype specific key mappings defined in +'~/.vim/ftplugin/c.vim'. + +Complete a classical C comment: '/*' => '/* | */' (modes: i,v). + +Complete a classical C multi-line comment (mode: i): + '/*<CR>' => /* + * | + */ + +Open a block (modes: i,v): + '{<CR>' => { + | + } +In visual mode the content of the new block will be indented. + +============================================================================== +10. WINDOWS PARTICULARITIES *csupport-windows* +============================================================================== + +The plugin should go into the directory structure below the local +installation directory $HOME/.vim/ for LINUX/UNIX and $VIM/vimfiles/ for +Windows. +The values of the two variables can be found from inside Vim: + :echo $VIM +or + :echo $HOME + +Configuration files: + + LINUX/UNIX : $HOME/.vimrc and $HOME/.gvimrc + Windows : $VIM/_vimrc and $VIM/_gvimrc + +Compiler settings: + +It could be necessary to add further settings for your compiler. To compile +C++-programs using a Dev-C++ installation (http://www.bloodshed.net) the +following item in $VIM/_vimrc is needed (depends on the Dev-C++ install +directory): + + let g:C_CFlags = '-Wall -g -o0 -c -I c:\programs\dev-c++\include\g++' + +============================================================================== +11. ADDITIONAL TIPS *csupport-tips* +============================================================================== + +(1) gVim. Toggle 'insert mode' <--> 'normal mode' with the right mouse button + (see mapping in file costumization.gvimrc). + +(2) gVim. Use tear off menus. + +(3) Try 'Focus under mouse' as window behavior (No mouse click when the mouse + pointer is back from the menu item). + +(4) Use Emulate3Buttons "on" (X11) even for a 3-button mouse. Pressing left + and right button at the same time without moving your fingers is faster + then moving a finger to the middle button (often a wheel). + +============================================================================== +12. TROUBLESHOOTING *csupport-troubleshooting* +============================================================================== + +* I do not see any new main menu item. + - Was the archive extracted into the right directory? + +* How can I see what was loaded? + - Use ':scriptnames' from the Vim command line. + +* No main menu item. + - Loading of plugin files must be enabled. If not use + :filetype plugin on + This is the minimal content of the file '$HOME/.vimrc'. Create one if there + is none, or better use customization.vimrc. + +* Most key mappings do not work. + - They are defined in a filetype plugin in '$HOME/.vim/ftplugin/'. Use + ':filetype' to check if filetype plugins are enabled. If not, add the line + filetype plugin on + to the file '~/.vimrc'. + +* Some hotkeys do not work. + - The hotkeys might be in use by your graphical desktop environment. Under + KDE Ctrl-F9 is the hotkey which let you switch to the 9. desktop. The key + settings can usually be redefined. + +* Splint and/or CodeCheck menu item not visible. + - The program is not installed or not found (path not set) or not executable. + +============================================================================== +13. RELEASE NOTES *csupport-release-notes* +============================================================================== +See file c-support/doc/ChangeLog . + +============================================================================== +vim:tw=78:noet:ts=2:ft=help:norl: diff --git a/.vim/doc/omnicppcomplete.txt b/.vim/doc/omnicppcomplete.txt new file mode 100644 index 0000000..b11e006 --- /dev/null +++ b/.vim/doc/omnicppcomplete.txt @@ -0,0 +1,1078 @@ +*omnicppcomplete.txt* Plugin for C/C++ omnicompletion +*omnicppcomplete* + +Author: Vissale NEANG (fromtonrouge AT gmail DOT com) +Last Change: 26 sept. 2007 + +OmniCppComplete version 0.41 + +For Vim version 7.0 and above + +============================================================================== + +1. Overview |omnicpp-overview| +2. Downloads |omnicpp-download| +3. Installation |omnicpp-installation| +4. Options |omnicpp-options| +5. Features |omnicpp-features| +6. Limitations |omnicpp-limitations| +7. FAQ & TIPS |omnicpp-faq| +8. History |omnicpp-history| +9. Thanks |omnicpp-thanks| + +============================================================================== +1. Overview~ + *omnicpp-overview* +The purpose of this script is to provide an 'omnifunc' function for C and C++ +language. In a C++ file, while in insert mode, you can use CTRL-X CTRL-O to: + + * Complete namespaces, classes, structs and unions + * Complete attribute members and return type of functions + * Complete the "this" pointer + * Complete an object after a cast (C and C++ cast) + * Complete typedefs and anonymous types + +You can set a "may complete" behaviour to start a completion automatically +after a '.', '->' or '::'. Please see |omnicpp-may-complete| for more details. + +The script needs an |Exuberant_ctags| database to work properly. + +============================================================================== +2. Downloads~ + *omnicpp-download* +You can download the latest release of the script from this url : + + http://www.vim.org/scripts/script.php?script_id=1520 + +You can download |Exuberant_ctags| from : + + http://ctags.sourceforge.net + +============================================================================== +3. Installation~ + *omnicpp-installation* +3.1. Script installation~ + +Unzip the downloaded file in your personal |vimfiles| directory (~/.vim under +unix or %HOMEPATH%\vimfiles under windows). The 'omnifunc' will be +automatically set for C and C++ files. + +You also have to enable plugins by adding these two lines in your|.vimrc|file: > + + set nocp + filetype plugin on +< +Please see |cp| and |filetype-plugin-on| sections for more details. + +3.1.1. Files~ + +After installation you should find these files : + + after\ftplugin\cpp.vim + after\ftplugin\c.vim + + autoload\omni\common\debug.vim + \utils.vim + + autoload\omni\cpp\complete.vim + \includes.vim + \items.vim + \maycomplete.vim + \namespaces.vim + \settings.vim + \tokenizer.vim + \utils.vim + + doc\omnicppcomplete.txt + +3.2. Building the Exuberant Ctags database~ + +To extract C/C++ symbols information, the script needs an |Exuberant_ctags| +database. + +You have to build your database with at least the following options: + --c++-kinds=+p : Adds prototypes in the database for C/C++ files. + --fields=+iaS : Adds inheritance (i), access (a) and function + signatures (S) information. + --extra=+q : Adds context to the tag name. Note: Without this + option, the script cannot get class members. + +Thus to build recursively a ctags database from the current directory, the +command looks like this: +> + ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . +< +You can add a map in your |.vimrc| file, eg: > + + map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR> +< +Or you can add these options in your ctags config file (~/.ctags under unix or +%HOMEPATH%\ctags.cnf under windows) and execute the command : > + + :!ctags -R . +< +If your project contains files of other languages you may add the following +options: + --languages=c++ : Builds only the tags for C++ files. + +If your project contains macros you may also use the -I option. + +Please read the ctags help or ctags man page for more details. + +3.3. Setting the 'tags' option~ + +The default value of the option 'tags' is "./tags,tags" ("./tags,./TAGS,tags,TAGS" +when |+emacs_tags| is enabled), if you build your tag database with the cmd above, +you normally don't have to change this setting (The cmd used above generates a +file with the name "tags"). In this case your current working directory must be +the directory where the tags file reside. + +Note: When |+emacs_tags| is enabled, the script may display members twice, it's + recommended to set tags to "./tags,tags' or "./TAGS,TAGS". + +If your tags file is not named "tags" you have to add it in the 'tags' +option eg: > + + set tags+=/usr/tagsdir/mytagfile +< +You can ensure that the 'tags' option is set properly by executing the following +command: > + + :tselect MyClass +< +Where MyClass is a class of your project. This command should display all +possible tags for the type MyClass. + +3.4. Simple test~ + +Now you can do a simple test. Edit a C++ file and write the simplest case : > + + MyClass myObject; + myObject.<C-X><C-O> +< +You should see class members of MyClass. + +============================================================================== +4. Options~ + *omnicpp-options* + +You can change completion behaviour by setting script options in your |.vimrc| +configuration file. + +4.1. Global scope search toggle~ + *OmniCpp_GlobalScopeSearch* + +You can enable/disable the global scope search by setting the +OmniCpp_GlobalScopeSearch option. + +Possible values are : + 0 = disabled + 1 = enabled + [default=1] > + + let OmniCpp_GlobalScopeSearch = 1 +< +4.2. Namespace search method~ + *OmniCpp_NamespaceSearch* + +You can change the 'using namespace' search behaviour by setting the +OmniCpp_NamespaceSearch option. + +Possible values are : + 0 = namespaces disabled + 1 = search namespaces in the current buffer + 2 = search namespaces in the current buffer and in included files + [default=1] > + + let OmniCpp_NamespaceSearch = 1 +< +When OmniCpp_NamespaceSearch is 2, "using namespace" declarations are parsed +in the current buffer and also in included files. To find included files, the +script use the vim env 'path', so you have to set it properly. + +Note: included files are searched with lvimgrep, thus the location list of the +current window is changed. + +Note: When the 'filetype' is "c", namespace search is always disabled even if +OmniCpp_NamespaceSearch != 0 + +4.3. Class scope completion mode~ + *OmniCpp_DisplayMode* + +When you are completing a class scope (eg: MyClass::<C-X><C-O>), depending on +the current scope, you may see sometimes static, public, protected or private +members and sometimes you may see all members. By default the choice is done +automatically by the script but you can override it with the +OmniCpp_DisplayMode option. + +Note: This option can be use when you have friend classes in your project (the +script does not support friend classes). + +Possible values are : + 0 = auto + 1 = always show all members + [default=0] > + + let OmniCpp_DisplayMode = 0 +< +4.4. Show scope in abbreviation~ + *OmniCpp_ShowScopeInAbbr* + +By default, in the |omnicpp-popup| menu, you will see the scope of a match in +the last column. You can remove this column and add the scope at the beginning +of match abbreviation. +eg: + +OmniCpp_ShowScopeInAbbr = 0 + +-------------------------------------+ + |method1( f + MyNamespace::MyClass| + |_member1 m + MyNamespace::MyClass| + |_member2 m # MyNamespace::MyClass| + |_member3 m - MyNamespace::MyClass| + +-------------------------------------+ + +OmniCpp_ShowScopeInAbbr = 1 + +-------------------------------------+ + |MyNamespace::MyClass::method1( f + | + |MyNamespace::MyClass::_member1 m + | + |MyNamespace::MyClass::_member2 m # | + |MyNamespace::MyClass::_member3 m - | + +-------------------------------------+ + +Possible values are : + 0 = don't show scope in abbreviation + 1 = show scope in abbreviation and remove the last column + [default=0] > + + let OmniCpp_ShowScopeInAbbr = 0 +< +4.5. Show prototype in abbreviation~ + *OmniCpp_ShowPrototypeInAbbr* + +This option allows to display the prototype of a function in the abbreviation +part of the popup menu. + +Possible values are: + 0 = don't display prototype in abbreviation + 1 = display prototype in abbreviation + [default=0] > + + let OmniCpp_ShowPrototypeInAbbr = 0 +< +4.6. Show access~ + *OmniCpp_ShowAccess* + +This option allows to show/hide the access information ('+', '#', '-') in the +popup menu. + +Possible values are: + 0 = hide access + 1 = show access + [default=1] > + + let OmniCpp_ShowAccess = 1 + +4.7. Default using namespace list~ + *OmniCpp_DefaultNamespaces* + +When |OmniCpp_NamespaceSearch| is not 0, the script will parse using namespace +declarations in the current buffer and maybe in included files. +You can specify manually a default namespace list if you want with the +OmniCpp_DefaultNamespaces option. Each item in the list is a namespace name. +eg: If you have + + let OmniCpp_DefaultNamespaces = ["std", "MyNamespace"] + + It will be the same as inserting this declarations at the top of the + current buffer : + + using namespace std; + using namespace MyNamespace; + +This option can be use if you don't want to parse using namespace declarations +in included files and want to add namespaces that are always used in your +project. + +Possible values are : + List of String + [default=[]] > + + let OmniCpp_DefaultNamespaces = [] +< +4.8. May complete behaviour~ + *omnicpp-may-complete* + +This feature allows you to run automatically a completion after a '.', '->' +or '::'. By default, the "may complete" feature is set automatically for '.' +and '->'. The reason to not set this feature for the scope operator '::' is +sometimes you don't want to complete a namespace that contains many members. + +To enable/disable the "may complete" behaviour for dot, arrow and scope +operator, you can change the option OmniCpp_MayCompleteDot, +OmniCpp_MayCompleteArrow and OmniCpp_MayCompleteScope respectively. + + *OmniCpp_MayCompleteDot* +Possible values are : + 0 = May complete disabled for dot + 1 = May complete enabled for dot + [default=1] > + + let OmniCpp_MayCompleteDot = 1 +< + *OmniCpp_MayCompleteArrow* +Possible values are : + 0 = May complete disabled for arrow + 1 = May complete enabled for arrow + [default=1] > + + let OmniCpp_MayCompleteArrow = 1 +< + *OmniCpp_MayCompleteScope* +Possible values are : + 0 = May complete disabled for scope + 1 = May complete enabled for scope + [default=0] > + + let OmniCpp_MayCompleteScope = 0 +< + +Note: You can obviously continue to use <C-X><C-O> + +4.9. Select/Don't select first popup item~ + *OmniCpp_SelectFirstItem* + +Note: This option is only used when 'completeopt' does not contain "longest". + +When 'completeopt' does not contain "longest", Vim automatically select the +first entry of the popup menu. You can change this behaviour with the +OmniCpp_SelectFirstItem option. + +Possible values are: + 0 = don't select first popup item + 1 = select first popup item (inserting it to the text) + 2 = select first popup item (without inserting it to the text) + [default=0] > + + let OmniCpp_SelectFirstItem = 0 + +4.10 Use local search function for variable definitions~ + *OmniCpp_LocalSearchDecl* + +The internal search function for variable definitions of vim requires that the +enclosing braces of the function are located in the first column. You can +change this behaviour with the OmniCpp_LocalSearchDecl option. The local +version works irrespective the position of braces. + +Possible values are: + 0 = use standard vim search function + 1 = use local search function + [default=0] > + +============================================================================== +5. Features~ + *omnicpp-features* +5.1. Popup menu~ + *omnicpp-popup* +Popup menu format: + +-------------------------------------+ + |method1( f + MyNamespace::MyClass| + |_member1 m + MyNamespace::MyClass| + |_member2 m # MyNamespace::MyClass| + |_member3 m - MyNamespace::MyClass| + +-------------------------------------+ + ^ ^ ^ ^ + (1) (2)(3) (4) + +(1) name of the symbol, when a match ends with '(' it's a function. + +(2) kind of the symbol, possible kinds are : + * c = classes + * d = macro definitions + * e = enumerators (values inside an enumeration) + * f = function definitions + * g = enumeration names + * m = class, struct, and union members + * n = namespaces + * p = function prototypes + * s = structure names + * t = typedefs + * u = union names + * v = variable definitions + +(3) access, possible values are : + * + = public + * # = protected + * - = private +Note: enumerators have no access information + +(4) scope where the symbol is defined. +Note: If the scope is empty it's a global symbol +Note: anonymous scope may end with __anon[number] +eg: If you have an anonymous enum in MyNamespace::MyClass : > + + namespace MyNamespace + { + class MyClass + { + private: + + enum + { + E_ENUM0, + E_ENUM1, + E_ENUM2 + }; + }; + } +< + +You should see : + + +----------------------------------------------+ + |E_ENUM0 e MyNamespace::MyClass::__anon1| + |E_ENUM1 e MyNamespace::MyClass::__anon1| + |E_ENUM2 e MyNamespace::MyClass::__anon1| + +----------------------------------------------+ + ^ + __anon[number] + +5.2. Global scope completion~ + +The global scope completion allows you to complete global symbols for the base +you are currently typing. The base can start with '::' or not. +Note: Global scope completion only works with a non empty base, if you run a +completion just after a '::' the completion will fail. The reason is that if +there is no base to complete the script will try to display all the tags in +the database. For small project it could be not a problem but for others you +may wait 5 minutes or more for a result. + +eg1 : > + + pthread_cr<C-X><C-O> => pthread_create +< +Where pthread_create is a global function. +eg2: > + ::globa<C-X><C-O> => ::global_func( + +----------------+ + |global_func( f| + |global_var1 v| + |global_var2 v| + +----------------+ +< +Where global_var1, global_var2 and global_func are global symbols +eg3: > + ::<C-X><C-O> => [NO MATCH] +< +No match because a global completion from an empty base is not allowed. + +5.3. Namespace scope completion~ + +You can complete namespace members after a 'MyNamespace::'. Contrary to global +scope completion you can run a completion from an empty base. +Possible members are: + * Namespaces + * Classes + * Structs + * Unions + * Enums + * Functions + * Variables + * Typedefs + +eg: > + MyNamespace::<C-X><C-O> + +--------------------------------+ + |E_ENUM0 e MyNamespace| + |E_ENUM1 e MyNamespace| + |E_ENUM2 e MyNamespace| + |MyClass c MyNamespace| + |MyEnum g MyNamespace| + |MyStruct s MyNamespace| + |MyUnion u MyNamespace| + |SubNamespace n MyNamespace| + |doSomething( f MyNamespace| + |myVar v MyNamespace| + |something_t t MyNamespace| + +--------------------------------+ + +5.4. Class scope completion~ + +You can complete class members after a 'MyClass::'. Contrary to global scope +completion you can run a completion from an empty base. +By default, there is two behaviours for class scope completion. + + a) Completion of a base class of the current class scope + + When you are completing a base class of the current class scope, you + will see all members of this class in the popup menu. + eg: > + + class A + { + public: + enum + { + E_ENUM0, + E_ENUM1, + E_ENUM2, + }; + + void func1(); + static int _staticMember; + + private: + int _member; + }; + + class B : public A + { + public: + void doSomething(); + }; + + + void MyClassB::doSomething() + { + MyClassA::<C-X><C-O> + +---------------------------+ + |E_ENUM0 e MyClassA| + |E_ENUM1 e MyClassA| + |E_ENUM2 e MyClassA| + |func1( f + MyClassA| + |_member m - MyClassA| + |_staticMember m + MyClassA| + +---------------------------+ + } +< + + b) Completion of a non base class of the current class scope + + When you are completing a class that is not a base class of the + current class you will see only enumerators and static members. + eg: > + + class C + { + public: + void doSomething(); + }; + + void MyClassC::doSomething() + { + MyClassA::<C-X><C-O> + +---------------------------+ + |E_ENUM0 e MyClassA| + |E_ENUM1 e MyClassA| + |E_ENUM2 e MyClassA| + |_staticMember m + MyClassA| + +---------------------------+ + } +< +You can override the default behaviour by setting the +|OmniCpp_DisplayMode| option. + +5.5. Current scope completion~ + +When you start a completion from an empty instruction you are in "Current +scope completion" mode. You will see possible members of each context in +the context stack. +eg: > + void MyClass::doSomething() + { + using namespace MyNamespace; + using namespace SubNamespace; + + // You will see members of each context in the context stack + // 1) MyClass members + // 2) MyNamespace::SubNamespace members + // 3) MyNamespace members + + <C-X><C-O> + +------------------------------------------+ + |_member1 m + MyClass | + |_member2 m # MyClass | + |func1( f MyNamespace::SubNamespace| + |var v MyNamespace::SubNamespace| + |func1( f MyNamespace | + |var v MyNamespace | + +------------------------------------------+ + } +< + +5.6. Class, Struct and Union members completion~ + +You can complete members of class, struct and union instances after a '->' or +'.'. +eg: > + MyClass myObject; + myObject.<C-X><C-O> + +-----------------------+ + |_member1 m + MyClass | + |_member2 m # MyClass | + +-----------------------+ +< + +5.7. Attribute members and returned type completion~ + +You can complete a class member or a return type of a function. +eg: > + MyClass myObject; + + // Completion of the member _member1 + myObject._member1-><C-X><C-O> + +------------------------+ + |get( m + AnotherClass1| + +------------------------+ + + // Completion of the return type of the function get() + myObject._member1->get()-><C-X><C-O> + +--------------------------+ + |_member1 m + AnotherClass2| + |_member2 m # AnotherClass2| + |_member3 m - AnotherClass2| + +--------------------------+ + +5.8. Anonymous type completion~ + +Note: To use this feature you need at least|Exuberant_ctags| version 5.6 + +You can complete an anonymous type like this : > + struct + { + int a; + int b; + int c; + }globalVar; + + void func() + { + globalVar.<C-X><C-O> + +---------------+ + |a m + __anon1| + |b m + __anon1| + |c m + __anon1| + +---------------+ + } +< +Where globalVar is a global variable of an anonymous type + +5.9. Typedef completion~ + +You can complete a typedef. The typedef is resolved recursively, thus typedef +of typedef of... may not be a problem. + +You can also complete a typedef of an anonymous type, eg : > + typedef struct + { + int a; + int b; + int c; + }something_t; + + something_t globalVar; + + void func() + { + globalVar.<C-X><C-O> + +---------------+ + |a m + __anon1| + |b m + __anon1| + |c m + __anon1| + +---------------+ + } +< +Where globalVar is a global variable of typedef of an anonymous type. + +5.10. Completion of the "this" pointer~ + +You can complete the "this" pointer. +eg: > + this-><C-X><C-O> + +-----------------------+ + |_member1 m + MyClass | + |_member2 m # MyClass | + +-----------------------+ + + (*this).<C-X><C-O> + +-----------------------+ + |_member1 m + MyClass | + |_member2 m # MyClass | + +-----------------------+ +< + +5.11. Completion after a cast~ + +You can complete an object after a C or C++ cast. +eg: > + // C cast style + ((AnotherStruct*)pStruct)-><C-X><C-O> + + // C++ cast style + static_cast<AnotherStruct*>(pStruct)-><C-X><C-O> +< + +5.12. Preview window~ + +If the 'completeopt' option contains the setting "preview" (this is the +default value), you will see a preview window during the completion. +This window shows useful information like function signature, filename where +the symbol is define etc... + +The preview window contains tag information, the list below is non exhaustive. + + * name : name of the tag + * cmd : regexp or line number that helps to find the tag + * signature : signature for prototypes and functions + * kind : kind of the tag (eg: namespace, class etc...) + * access : access information (eg: public, protected, private) + * inherits : list of base classes + * filename : filename where the tag is define + +5.13. Code tokenization~ + +When you start a completion, the current instruction is tokenized ignoring +spaces, tabs, carriage returns and comments. Thus you can complete a symbol +even if the current instruction is on multiple lines, has comments between +words etc... : +eg: this case is unrealistic but it's just for illustration > + + myObject [ 0 ]/* Why is there a comment here ?*/ + ->_member + -> <C-X><C-O> +< + +============================================================================== +6. Limitations~ + *omnicpp-limitations* +Some C++ features are not supported by the script, some implemented features +may not work properly in some conditions. They are multiple reasons like a +lack of information in the database, performance issues and so on... + +6.1. Attribute members and returned type completion~ + +To work properly, the completion of attribute members and returned type of +functions depends on how you write your code in the class declaration. +Because the tags database does not contain information like return type or +type of a member, the script use the cmd information of the tag to determine +the type of an attribute member or the return type of a function. + +Thus, because the cmd is a regular expression (or line number for #define) if +you write your code like this : > + + class MyClass + { + public: + + MyOtherClass + _member; + }; +< +The type of _member will not be recognized, because the cmd will be +/^ _member;$/ and does not contain the type MyOtherClass. +The correct case should be : > + + class MyClass + { + public: + + MyOtherClass _member; + }; +< +It's the same problem for return type of function : > + + class MyClass + { + public: + + MyOtherClass + getOtherClass(); + }; +< +Here the cmd will be /^ getOtherClass();$/ and the script won't find the +return type. +The correct case should be : > + class MyClass + { + public: + + MyOtherClass getOtherClass(); + }; +< + +6.2. Static members~ + +It's the same problem as above, tags database does not contain information +about static members. The only fast way to get this information is to use the +cmd. + +6.3. Typedef~ + +It's the same problem as above, tags database does not contain information +about the type of a typedef. The script use the cmd information to resolve the +typedef. + +6.4. Restricted inheritance access~ + +Tags database contains inheritance information but unfortunately inheritance +access are not available. We could use the cmd but we often find code +indentation like this : > + + class A : + public B, + protected C, + private D + { + }; +< +Here the cmd will be /^class A :$/, we can't extract inheritance access. + +6.5. Using namespace parsing~ + +When you start a completion, using namespace declarations are parsed from the +cursor position to the first scope to detect local using namespace +declarations. After that, global using namespace declarations are parsed in the +file and included files. + +There is a limitation for global using namespace detection, for performance +issues only using namespace that starts a line will be detected. + +6.6. Friend classes~ + +Tags database does not contain information about friend classes. The script +does not support friend classes. + +6.7. Templates~ + +At the moment, |Exuberant_ctags| does not provide additional information for +templates. That's why the script does not handle templates. + +============================================================================== +7. FAQ & TIPS~ + *omnicpp-faq* + +* How to complete STL objects ? + If you have some troubles to generate a good ctags database for STL you + can try this solution : + + 1) Download SGI's STL from SGI's site + (http://www.sgi.com/tech/stl/download.html) + 2) Replace all __STL_BEGIN_NAMESPACE by "namespace std {" and + __STL_END_NAMESPACE by "}" from header and source files. (with Vim, + or with tar and sed or another tool) + 3) Run ctags and put the generated tags file in a directory eg: + ~/MyTags/stl.tags + 4) set tags+=~/MyTags/stl.tags + + The main problem is that you can't tell to ctags that + __STL_BEGIN_NAMESPACE = "namespace std {" even with the option -I. + That's why you need the step 2). + + Here is another solution if you have STL sources using _GLIBCXX_STD macro + (Tip by Nicola Bonelli) : > + + let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] +< +* How to close automatically the preview window after a completion ? + (Tip by Kamil Renczewski) + + You can add to your |vimrc| the following lines : > + + autocmd CursorMovedI * if pumvisible() == 0|pclose|endif + autocmd InsertLeave * if pumvisible() == 0|pclose|endif +< +============================================================================== +8. History~ + *omnicpp-history* +Version O.41 + - It's recommended to update ctags to version 5.7 or higher + - The plugin is now activated for C files + - New value for OmniCpp_SelectFirstItem when the option is equal to + 2 the first item is selected without inserting it to + the text (patch from Marek Olszewski) + - Bug when completing union members fixed with ctags 5.7 + (reported by Willem-Jan de Hoog) + - New option OmniCpp_LocalSearchDecl (patch from Roland Kuck) + - Bug when tags=something,,somethingelse (reported by Tobias Pflug) + - Bug with nested structure (reported by Mikhail Daen) + - Bug where the script fails to detect the type of a variable when + the ignorecase option is on (reported by Alexey Vakhov) + - Error message when trying to use completion on a not yet saved + Vim buffer (reported by Neil Bird) + - Error message when trying to use completion on an file opened from + a tselect command (reported by Henrique Andrade) + +Version 0.4 + - The script is renamed to OmniCppComplete according to the library + script directory structure. + - OmniCpp_ClassScopeCompletionMethod renamed to OmniCpp_DisplayMode + - Fixed a bug where the quickfix list is modified after a completion. + - OmniCpp_ShowPrototypeInAbbr option added. It allows to show the + function signature in the abbreviation. + - OmniCpp_ShowAccess option added. It allows to hide the access + information in the popup menu. + - The tags database format must be a ctags 5.6 database if you want to + complete anonymous types. + - Fixed current scope detection not working properly in destructors. + - Don't show protected and private members according to the current scope. + - Overloaded functions are now filtered properly. + - New cache system using less memory. + - The class scope of a method is now resolved properly with "using + namespace" declarations. + - OmniCpp_SelectFirstItem option added. It allows to not select the first + item in the popup menu when 'completeopt' does not contain "longest". + - Fixed the bug where a "random" item in the popup menu is selected + by default when 'completeopt' does not contain "longest" option. + - The script is now split in library scripts. + - Cache added for 'using namespace' search in included files + - Default value for OmniCpp_NamespaceSearch is now 1 (search only in the + current buffer). + - Namespace search automatically disabled for C files even if + OmniCpp_NamespaceSearch != 0. + - To avoid linear search in tags files, the ignorecase option is now + disabled when getting tags datas (the user setting is restored after). + - Fixed a bug where friend functions may crash the script and also crash vim. + +Version 0.32 + - Optimizations in search members methods. + - 'May complete' behaviour is now set to default for dot '.' and arrow + '->' (mappings are set in after/ftplugin/cpp.vim) + - Fixed the option CppOmni_ShowScopeInAbbr not detected after the first + completion. + - Exceptions catched from taglist() when a tag file is corrupted. + - Fixed a bug where enumerators in global scope didn't appear in the + popup menu. + +Version 0.31 + WARNING: For this release and future releases you have to build your tags + database with this cmd : + "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ." + Please read installation instructions in the documentation for details + + - May complete added, please see installation notes for details. + - Fixed a bug where the completion works while in a comment or in a string. + +Version 0.3 + WARNING: For this release and future releases you have to build your tags + database with this cmd : + "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ." + Please read installation instructions in the documentation for details + + - Documentation added. + - Fixed a bug where typedefs were not correctly resolved in namespaces + in some cases. + - Fixed a bug where the type can not be detected when we have a decl + like this: class A {}globalVar; + - Fixed a bug in type detection where searchdecl() (gd) find + incorrect declaration instruction. + - Global scope completion now only works with non-empty base. + - Using namespace list is now parsed in the current buffer and in + included files. + - Fixed a bug where the completion fails in some cases when the user + sets the ignorecase to on + - Preview window information added + - Some improvements in type detection, the type can be properly detected + with a declaration like this: + 'Class1 *class1A = NULL, **class1B = NULL, class1C[9], class1D[1] = {};' + - Fixed a bug where parent scopes were not displayed in the popup menu + in the current scope completion mode. + - Fixed a bug where an error message was displayed when the last + instruction was not finished. + - Fixed a bug where the completion fails if a punctuator or operator was + immediately after the cursor. + - The script can now detect parent contexts at the cursor position + thanks to 'using namespace' declarations. + It can also detect ambiguous namespaces. They are not included in + the context list. + - Fixed a bug where the current scope is not properly detected when + a file starts with a comment + - Fixed a bug where the type is not detected when we have myObject[0] + - Removed the system() call in SearchMembers(), no more calls to the + ctags binary. The user have to build correctly his database with the cmd: + "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ." + - File time cache removed, the user have to rebuild his data base after a + modification. + +Version 0.22 + - Completion of unnamed type (eg: You can complete g_Var defined like + this 'struct {int a; int b;}g_Var;'). It also works for a typedef of + an unnamed type (eg: 'typedef struct {int a; int b;}t_mytype; t_mytype + g_Var;'). + - Tag file's time cache added, if a tag file has changed the global + scope result cache is cleared. + - Fixed a bug where the tokenization process enter in an infinite loop + when a file starts with '/*'. + +Version 0.21 + - Improvements on the global scope completion. + The user can now see the progression of the search and complete + matches are stored in a cache for optimization. The cache is cleared + when the tag env is modified. + - Within a class scope when the user complete an empty word, the popup + menu displays the members of the class then members of the global + scope. + - Fixed a bug where a current scope completion failed after a punctuator + or operator (eg: after a '=' or '!='). + +Version 0.2 + - Improvements in type detection (eg: when a variable is declared in a + parameter list, a catch clause, etc...) + - Code tokenization => ignoring spaces, tabs, carriage returns and comments + You can complete a code even if the instruction has bad + indentation, spaces or carriage returns between words + - Completion of class members added + - Detection of the current scope at the cursor position. + If you run a completion from en empty line, members of the current + scope are displayed. It works on the global namespace and the current + class scope (but there is not the combination of the 2 for the moment) + - Basic completion on the global namespace (very slow) + - Completion of returned type added + - this pointer completion added + - Completion after a cast added (C and C++ cast) + - Fixed a bug where the matches of the complete menu are not filtered + according to what the user typed + - Change the output of the popup menu. The type of the member + (function, member, enum etc...) is now display as a single letter. + The access information is display like this : '+' for a public member + '#' for a protected member and '-' for a private member. + The last information is the class, namespace or enum where the member is define. + +Version 0.12: + - Complete check added to the search process, you can now cancel + the search during a complete search. + +Version 0.1: + - First release + +============================================================================== +9. Thanks~ + *omnicpp-thanks* + * For advices, bug report, documentation, help, ideas : + Alexey Vakhov (bug report) + Arthur Axel "fREW" Schmidt (documentation) + Dennis Lubert (bug report) + Henrique Andrade (bug report) + Kamil Renczewski (tips) + Marek Olszewski (patch) + Markus Trenkwalder (bug report) + Martin Stubenschrott (bug report) + Mikhail Daen (bug report) + Neil Bird (bug report) + Nicola Bonelli (tips) + Robert Webb (bug report) + Roland Kuck (patch) + Tobias Pflug (bug report) + Willem-Jan de Hoog (bug report) + Yegappan Lakshmanan (advices) + + + * Darren Hiebert for Exuberant Ctags + + * All Vim devs for Vim + + * Bram Moolenaar for Vim + + * You for using this script :) + +============================================================================== + + vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl: diff --git a/.vim/doc/tags b/.vim/doc/tags new file mode 100644 index 0000000..422861c --- /dev/null +++ b/.vim/doc/tags @@ -0,0 +1,1374 @@ +:CS cecscope.txt /*:CS* +:CSH cecscope.txt /*:CSH* +:CSL cecscope.txt /*:CSL* +:CSS cecscope.txt /*:CSS* +C-Reference crefvim.txt /*C-Reference* +OmniCpp_DefaultNamespaces omnicppcomplete.txt /*OmniCpp_DefaultNamespaces* +OmniCpp_DisplayMode omnicppcomplete.txt /*OmniCpp_DisplayMode* +OmniCpp_GlobalScopeSearch omnicppcomplete.txt /*OmniCpp_GlobalScopeSearch* +OmniCpp_LocalSearchDecl omnicppcomplete.txt /*OmniCpp_LocalSearchDecl* +OmniCpp_MayCompleteArrow omnicppcomplete.txt /*OmniCpp_MayCompleteArrow* +OmniCpp_MayCompleteDot omnicppcomplete.txt /*OmniCpp_MayCompleteDot* +OmniCpp_MayCompleteScope omnicppcomplete.txt /*OmniCpp_MayCompleteScope* +OmniCpp_NamespaceSearch omnicppcomplete.txt /*OmniCpp_NamespaceSearch* +OmniCpp_SelectFirstItem omnicppcomplete.txt /*OmniCpp_SelectFirstItem* +OmniCpp_ShowAccess omnicppcomplete.txt /*OmniCpp_ShowAccess* +OmniCpp_ShowPrototypeInAbbr omnicppcomplete.txt /*OmniCpp_ShowPrototypeInAbbr* +OmniCpp_ShowScopeInAbbr omnicppcomplete.txt /*OmniCpp_ShowScopeInAbbr* +c-support csupport.txt /*c-support* +cecscope-contents cecscope.txt /*cecscope-contents* +cecscope-copyright cecscope.txt /*cecscope-copyright* +cecscope-history cecscope.txt /*cecscope-history* +cecscope-install cecscope.txt /*cecscope-install* +cecscope-manual cecscope.txt /*cecscope-manual* +cecscope-tutorial cecscope.txt /*cecscope-tutorial* +cecscope.txt cecscope.txt /*cecscope.txt* +crefvim crefvim.txt /*crefvim* +crefvim.txt crefvim.txt /*crefvim.txt* +crefvimdoc crefvimdoc.txt /*crefvimdoc* +crefvimdoc.txt crefvimdoc.txt /*crefvimdoc.txt* +crv-# crefvim.txt /*crv-#* +crv-## crefvim.txt /*crv-##* +crv-#define crefvim.txt /*crv-#define* +crv-#elif crefvim.txt /*crv-#elif* +crv-#else crefvim.txt /*crv-#else* +crv-#endif crefvim.txt /*crv-#endif* +crv-#error crefvim.txt /*crv-#error* +crv-#if crefvim.txt /*crv-#if* +crv-#ifdef crefvim.txt /*crv-#ifdef* +crv-#ifndef crefvim.txt /*crv-#ifndef* +crv-#include crefvim.txt /*crv-#include* +crv-#line crefvim.txt /*crv-#line* +crv-#pragma crefvim.txt /*crv-#pragma* +crv-#undef crefvim.txt /*crv-#undef* +crv-BUFSIZ crefvim.txt /*crv-BUFSIZ* +crv-CHAR_BIT crefvim.txt /*crv-CHAR_BIT* +crv-CHAR_MAX crefvim.txt /*crv-CHAR_MAX* +crv-CHAR_MIN crefvim.txt /*crv-CHAR_MIN* +crv-CLOCKS_PER_SEC crefvim.txt /*crv-CLOCKS_PER_SEC* +crv-CX_LIMITED_RANGE crefvim.txt /*crv-CX_LIMITED_RANGE* +crv-DBL_DIG crefvim.txt /*crv-DBL_DIG* +crv-DBL_EPSILON crefvim.txt /*crv-DBL_EPSILON* +crv-DBL_MANT_DIG crefvim.txt /*crv-DBL_MANT_DIG* +crv-DBL_MAX crefvim.txt /*crv-DBL_MAX* +crv-DBL_MAX_10_EXP crefvim.txt /*crv-DBL_MAX_10_EXP* +crv-DBL_MAX_EXP crefvim.txt /*crv-DBL_MAX_EXP* +crv-DBL_MIN crefvim.txt /*crv-DBL_MIN* +crv-DBL_MIN_10_EXP crefvim.txt /*crv-DBL_MIN_10_EXP* +crv-DBL_MIN_EXP crefvim.txt /*crv-DBL_MIN_EXP* +crv-EDOM crefvim.txt /*crv-EDOM* +crv-EILSEQ crefvim.txt /*crv-EILSEQ* +crv-EOF crefvim.txt /*crv-EOF* +crv-ERANGE crefvim.txt /*crv-ERANGE* +crv-EXIT_FAILURE crefvim.txt /*crv-EXIT_FAILURE* +crv-EXIT_SUCCESS crefvim.txt /*crv-EXIT_SUCCESS* +crv-FENV_ACCESS crefvim.txt /*crv-FENV_ACCESS* +crv-FE_ALL_EXCEPT crefvim.txt /*crv-FE_ALL_EXCEPT* +crv-FE_DIVBYZERO crefvim.txt /*crv-FE_DIVBYZERO* +crv-FE_DOWNWARD crefvim.txt /*crv-FE_DOWNWARD* +crv-FE_INEXACT crefvim.txt /*crv-FE_INEXACT* +crv-FE_INVALID crefvim.txt /*crv-FE_INVALID* +crv-FE_OVERFLOW crefvim.txt /*crv-FE_OVERFLOW* +crv-FE_TONEAREST crefvim.txt /*crv-FE_TONEAREST* +crv-FE_TOWARDZERO crefvim.txt /*crv-FE_TOWARDZERO* +crv-FE_UNDERFLOW crefvim.txt /*crv-FE_UNDERFLOW* +crv-FE_UPWARD crefvim.txt /*crv-FE_UPWARD* +crv-FILE crefvim.txt /*crv-FILE* +crv-FILENAME_MAX crefvim.txt /*crv-FILENAME_MAX* +crv-FLT_DIG crefvim.txt /*crv-FLT_DIG* +crv-FLT_EPSILON crefvim.txt /*crv-FLT_EPSILON* +crv-FLT_MANT_DIG crefvim.txt /*crv-FLT_MANT_DIG* +crv-FLT_MAX crefvim.txt /*crv-FLT_MAX* +crv-FLT_MAX_10_EXP crefvim.txt /*crv-FLT_MAX_10_EXP* +crv-FLT_MAX_EXP crefvim.txt /*crv-FLT_MAX_EXP* +crv-FLT_MIN crefvim.txt /*crv-FLT_MIN* +crv-FLT_MIN_10_EXP crefvim.txt /*crv-FLT_MIN_10_EXP* +crv-FLT_MIN_EXP crefvim.txt /*crv-FLT_MIN_EXP* +crv-FLT_RADIX crefvim.txt /*crv-FLT_RADIX* +crv-FLT_ROUNDS crefvim.txt /*crv-FLT_ROUNDS* +crv-FOPEN_MAX crefvim.txt /*crv-FOPEN_MAX* +crv-FP_FAST_FMA crefvim.txt /*crv-FP_FAST_FMA* +crv-FP_FAST_FMAF crefvim.txt /*crv-FP_FAST_FMAF* +crv-FP_FAST_FMAL crefvim.txt /*crv-FP_FAST_FMAL* +crv-FP_ILOGB0 crefvim.txt /*crv-FP_ILOGB0* +crv-FP_ILOGBNAN crefvim.txt /*crv-FP_ILOGBNAN* +crv-HUGE_VAL crefvim.txt /*crv-HUGE_VAL* +crv-HUGE_VALF crefvim.txt /*crv-HUGE_VALF* +crv-HUGE_VALL crefvim.txt /*crv-HUGE_VALL* +crv-I crefvim.txt /*crv-I* +crv-INT16_C crefvim.txt /*crv-INT16_C* +crv-INT16_MAX crefvim.txt /*crv-INT16_MAX* +crv-INT16_MIN crefvim.txt /*crv-INT16_MIN* +crv-INT32_C crefvim.txt /*crv-INT32_C* +crv-INT32_MAX crefvim.txt /*crv-INT32_MAX* +crv-INT32_MIN crefvim.txt /*crv-INT32_MIN* +crv-INT64_C crefvim.txt /*crv-INT64_C* +crv-INT64_MAX crefvim.txt /*crv-INT64_MAX* +crv-INT64_MIN crefvim.txt /*crv-INT64_MIN* +crv-INT8_C crefvim.txt /*crv-INT8_C* +crv-INT8_MAX crefvim.txt /*crv-INT8_MAX* +crv-INT8_MIN crefvim.txt /*crv-INT8_MIN* +crv-INTMAX_C crefvim.txt /*crv-INTMAX_C* +crv-INTMAX_MAX crefvim.txt /*crv-INTMAX_MAX* +crv-INTMAX_MIN crefvim.txt /*crv-INTMAX_MIN* +crv-INTPTR_MAX crefvim.txt /*crv-INTPTR_MAX* +crv-INTPTR_MIN crefvim.txt /*crv-INTPTR_MIN* +crv-INT_FAST16_MAX crefvim.txt /*crv-INT_FAST16_MAX* +crv-INT_FAST16_MIN crefvim.txt /*crv-INT_FAST16_MIN* +crv-INT_FAST32_MAX crefvim.txt /*crv-INT_FAST32_MAX* +crv-INT_FAST32_MIN crefvim.txt /*crv-INT_FAST32_MIN* +crv-INT_FAST64_MAX crefvim.txt /*crv-INT_FAST64_MAX* +crv-INT_FAST64_MIN crefvim.txt /*crv-INT_FAST64_MIN* +crv-INT_FAST8_MAX crefvim.txt /*crv-INT_FAST8_MAX* +crv-INT_FAST8_MIN crefvim.txt /*crv-INT_FAST8_MIN* +crv-INT_LEAST16_MAX crefvim.txt /*crv-INT_LEAST16_MAX* +crv-INT_LEAST16_MIN crefvim.txt /*crv-INT_LEAST16_MIN* +crv-INT_LEAST32_MAX crefvim.txt /*crv-INT_LEAST32_MAX* +crv-INT_LEAST32_MIN crefvim.txt /*crv-INT_LEAST32_MIN* +crv-INT_LEAST64_MAX crefvim.txt /*crv-INT_LEAST64_MAX* +crv-INT_LEAST64_MIN crefvim.txt /*crv-INT_LEAST64_MIN* +crv-INT_LEAST8_MAX crefvim.txt /*crv-INT_LEAST8_MAX* +crv-INT_LEAST8_MIN crefvim.txt /*crv-INT_LEAST8_MIN* +crv-INT_MAX crefvim.txt /*crv-INT_MAX* +crv-INT_MIN crefvim.txt /*crv-INT_MIN* +crv-LC_ALL crefvim.txt /*crv-LC_ALL* +crv-LC_COLLATE crefvim.txt /*crv-LC_COLLATE* +crv-LC_CTYPE crefvim.txt /*crv-LC_CTYPE* +crv-LC_MONETARY crefvim.txt /*crv-LC_MONETARY* +crv-LC_NUMERIC crefvim.txt /*crv-LC_NUMERIC* +crv-LDBL_DIG crefvim.txt /*crv-LDBL_DIG* +crv-LDBL_EPSILON crefvim.txt /*crv-LDBL_EPSILON* +crv-LDBL_MANT_DIG crefvim.txt /*crv-LDBL_MANT_DIG* +crv-LDBL_MAX crefvim.txt /*crv-LDBL_MAX* +crv-LDBL_MAX_10_EXP crefvim.txt /*crv-LDBL_MAX_10_EXP* +crv-LDBL_MAX_EXP crefvim.txt /*crv-LDBL_MAX_EXP* +crv-LDBL_MIN crefvim.txt /*crv-LDBL_MIN* +crv-LDBL_MIN_10_EXP crefvim.txt /*crv-LDBL_MIN_10_EXP* +crv-LDBL_MIN_EXP crefvim.txt /*crv-LDBL_MIN_EXP* +crv-LONG_LONG_MAX crefvim.txt /*crv-LONG_LONG_MAX* +crv-LONG_LONG_MIN crefvim.txt /*crv-LONG_LONG_MIN* +crv-LONG_MAX crefvim.txt /*crv-LONG_MAX* +crv-LONG_MIN crefvim.txt /*crv-LONG_MIN* +crv-L_tmpnam crefvim.txt /*crv-L_tmpnam* +crv-MB_CUR_MAX crefvim.txt /*crv-MB_CUR_MAX* +crv-MB_LEN_MAX crefvim.txt /*crv-MB_LEN_MAX* +crv-NDEBUG crefvim.txt /*crv-NDEBUG* +crv-NULL crefvim.txt /*crv-NULL* +crv-NULL2 crefvim.txt /*crv-NULL2* +crv-NULL3 crefvim.txt /*crv-NULL3* +crv-NULL4 crefvim.txt /*crv-NULL4* +crv-NULL5 crefvim.txt /*crv-NULL5* +crv-NULL6 crefvim.txt /*crv-NULL6* +crv-PRIXFASTN crefvim.txt /*crv-PRIXFASTN* +crv-PRIXLEASTN crefvim.txt /*crv-PRIXLEASTN* +crv-PRIXMAX crefvim.txt /*crv-PRIXMAX* +crv-PRIXN crefvim.txt /*crv-PRIXN* +crv-PRIXPTR crefvim.txt /*crv-PRIXPTR* +crv-PRIdFASTN crefvim.txt /*crv-PRIdFASTN* +crv-PRIdLEASTN crefvim.txt /*crv-PRIdLEASTN* +crv-PRIdMAX crefvim.txt /*crv-PRIdMAX* +crv-PRIdN crefvim.txt /*crv-PRIdN* +crv-PRIdPTR crefvim.txt /*crv-PRIdPTR* +crv-PRIiFASTN crefvim.txt /*crv-PRIiFASTN* +crv-PRIiLEASTN crefvim.txt /*crv-PRIiLEASTN* +crv-PRIiMAX crefvim.txt /*crv-PRIiMAX* +crv-PRIiN crefvim.txt /*crv-PRIiN* +crv-PRIiPTR crefvim.txt /*crv-PRIiPTR* +crv-PRIoFASTN crefvim.txt /*crv-PRIoFASTN* +crv-PRIoLEASTN crefvim.txt /*crv-PRIoLEASTN* +crv-PRIoMAX crefvim.txt /*crv-PRIoMAX* +crv-PRIoN crefvim.txt /*crv-PRIoN* +crv-PRIoPTR crefvim.txt /*crv-PRIoPTR* +crv-PRIuFASTN crefvim.txt /*crv-PRIuFASTN* +crv-PRIuLEASTN crefvim.txt /*crv-PRIuLEASTN* +crv-PRIuMAX crefvim.txt /*crv-PRIuMAX* +crv-PRIuN crefvim.txt /*crv-PRIuN* +crv-PRIuPTR crefvim.txt /*crv-PRIuPTR* +crv-PRIxFASTN crefvim.txt /*crv-PRIxFASTN* +crv-PRIxLEASTN crefvim.txt /*crv-PRIxLEASTN* +crv-PRIxMAX crefvim.txt /*crv-PRIxMAX* +crv-PRIxN crefvim.txt /*crv-PRIxN* +crv-PRIxPTR crefvim.txt /*crv-PRIxPTR* +crv-PTRDIFF_MAX crefvim.txt /*crv-PTRDIFF_MAX* +crv-PTRDIFF_MIN crefvim.txt /*crv-PTRDIFF_MIN* +crv-PreInc crefvim.txt /*crv-PreInc* +crv-RAND_MAX crefvim.txt /*crv-RAND_MAX* +crv-SCHAR_MAX crefvim.txt /*crv-SCHAR_MAX* +crv-SCHAR_MIN crefvim.txt /*crv-SCHAR_MIN* +crv-SCNdFASTN crefvim.txt /*crv-SCNdFASTN* +crv-SCNdLEASTN crefvim.txt /*crv-SCNdLEASTN* +crv-SCNdMAX crefvim.txt /*crv-SCNdMAX* +crv-SCNdN crefvim.txt /*crv-SCNdN* +crv-SCNdPTR crefvim.txt /*crv-SCNdPTR* +crv-SCNiFASTN crefvim.txt /*crv-SCNiFASTN* +crv-SCNiLEASTN crefvim.txt /*crv-SCNiLEASTN* +crv-SCNiMAX crefvim.txt /*crv-SCNiMAX* +crv-SCNiN crefvim.txt /*crv-SCNiN* +crv-SCNiPTR crefvim.txt /*crv-SCNiPTR* +crv-SCNoFASTN crefvim.txt /*crv-SCNoFASTN* +crv-SCNoLEASTN crefvim.txt /*crv-SCNoLEASTN* +crv-SCNoMAX crefvim.txt /*crv-SCNoMAX* +crv-SCNoN crefvim.txt /*crv-SCNoN* +crv-SCNoPTR crefvim.txt /*crv-SCNoPTR* +crv-SCNuFASTN crefvim.txt /*crv-SCNuFASTN* +crv-SCNuLEASTN crefvim.txt /*crv-SCNuLEASTN* +crv-SCNuMAX crefvim.txt /*crv-SCNuMAX* +crv-SCNuN crefvim.txt /*crv-SCNuN* +crv-SCNuPTR crefvim.txt /*crv-SCNuPTR* +crv-SCNxFASTN crefvim.txt /*crv-SCNxFASTN* +crv-SCNxLEASTN crefvim.txt /*crv-SCNxLEASTN* +crv-SCNxMAX crefvim.txt /*crv-SCNxMAX* +crv-SCNxN crefvim.txt /*crv-SCNxN* +crv-SCNxPTR crefvim.txt /*crv-SCNxPTR* +crv-SEEK_CUR crefvim.txt /*crv-SEEK_CUR* +crv-SEEK_END crefvim.txt /*crv-SEEK_END* +crv-SEEK_SET crefvim.txt /*crv-SEEK_SET* +crv-SHRT_MAX crefvim.txt /*crv-SHRT_MAX* +crv-SHRT_MIN crefvim.txt /*crv-SHRT_MIN* +crv-SIGABRT crefvim.txt /*crv-SIGABRT* +crv-SIGFPE crefvim.txt /*crv-SIGFPE* +crv-SIGILL crefvim.txt /*crv-SIGILL* +crv-SIGINT crefvim.txt /*crv-SIGINT* +crv-SIGSEGV crefvim.txt /*crv-SIGSEGV* +crv-SIGTERM crefvim.txt /*crv-SIGTERM* +crv-SIG_ATOMIC_MAX crefvim.txt /*crv-SIG_ATOMIC_MAX* +crv-SIG_ATOMIC_MIN crefvim.txt /*crv-SIG_ATOMIC_MIN* +crv-SIG_DFL crefvim.txt /*crv-SIG_DFL* +crv-SIG_ERR crefvim.txt /*crv-SIG_ERR* +crv-SIG_IGN crefvim.txt /*crv-SIG_IGN* +crv-SIZE_MAX crefvim.txt /*crv-SIZE_MAX* +crv-TMP_MAX crefvim.txt /*crv-TMP_MAX* +crv-UCHAR_MAX crefvim.txt /*crv-UCHAR_MAX* +crv-UINT16_C crefvim.txt /*crv-UINT16_C* +crv-UINT16_MAX crefvim.txt /*crv-UINT16_MAX* +crv-UINT32_C crefvim.txt /*crv-UINT32_C* +crv-UINT32_MAX crefvim.txt /*crv-UINT32_MAX* +crv-UINT64_C crefvim.txt /*crv-UINT64_C* +crv-UINT64_MAX crefvim.txt /*crv-UINT64_MAX* +crv-UINT8_C crefvim.txt /*crv-UINT8_C* +crv-UINT8_MAX crefvim.txt /*crv-UINT8_MAX* +crv-UINTMAX_C crefvim.txt /*crv-UINTMAX_C* +crv-UINTMAX_MAX crefvim.txt /*crv-UINTMAX_MAX* +crv-UINTPTR_MAX crefvim.txt /*crv-UINTPTR_MAX* +crv-UINT_FAST16_MAX crefvim.txt /*crv-UINT_FAST16_MAX* +crv-UINT_FAST32_MAX crefvim.txt /*crv-UINT_FAST32_MAX* +crv-UINT_FAST64_MAX crefvim.txt /*crv-UINT_FAST64_MAX* +crv-UINT_FAST8_MAX crefvim.txt /*crv-UINT_FAST8_MAX* +crv-UINT_LEAST16_MAX crefvim.txt /*crv-UINT_LEAST16_MAX* +crv-UINT_LEAST32_MAX crefvim.txt /*crv-UINT_LEAST32_MAX* +crv-UINT_LEAST64_MAX crefvim.txt /*crv-UINT_LEAST64_MAX* +crv-UINT_LEAST8_MAX crefvim.txt /*crv-UINT_LEAST8_MAX* +crv-UINT_MAX crefvim.txt /*crv-UINT_MAX* +crv-ULONG_LONG_MAX crefvim.txt /*crv-ULONG_LONG_MAX* +crv-ULONG_MAX crefvim.txt /*crv-ULONG_MAX* +crv-USHRT_MAX crefvim.txt /*crv-USHRT_MAX* +crv-WCHAR_MAX crefvim.txt /*crv-WCHAR_MAX* +crv-WCHAR_MAX2 crefvim.txt /*crv-WCHAR_MAX2* +crv-WCHAR_MIN crefvim.txt /*crv-WCHAR_MIN* +crv-WCHAR_MIN2 crefvim.txt /*crv-WCHAR_MIN2* +crv-WEOF crefvim.txt /*crv-WEOF* +crv-WEOF2 crefvim.txt /*crv-WEOF2* +crv-WINT_MAX crefvim.txt /*crv-WINT_MAX* +crv-WINT_MIN crefvim.txt /*crv-WINT_MIN* +crv-_Bool crefvim.txt /*crv-_Bool* +crv-_Complex crefvim.txt /*crv-_Complex* +crv-_Complex_I crefvim.txt /*crv-_Complex_I* +crv-_Exit crefvim.txt /*crv-_Exit* +crv-_IOFBF crefvim.txt /*crv-_IOFBF* +crv-_IOLBF crefvim.txt /*crv-_IOLBF* +crv-_IONBF crefvim.txt /*crv-_IONBF* +crv-_Imaginary crefvim.txt /*crv-_Imaginary* +crv-_Imaginary_I crefvim.txt /*crv-_Imaginary_I* +crv-__DATA__ crefvim.txt /*crv-__DATA__* +crv-__FILE__ crefvim.txt /*crv-__FILE__* +crv-__LINE__ crefvim.txt /*crv-__LINE__* +crv-__STDC_FORMAT_MACROS crefvim.txt /*crv-__STDC_FORMAT_MACROS* +crv-__STDC_HOSTED__ crefvim.txt /*crv-__STDC_HOSTED__* +crv-__STDC_IEC_559_COMPLEX__ crefvim.txt /*crv-__STDC_IEC_559_COMPLEX__* +crv-__STDC_IEC_559__ crefvim.txt /*crv-__STDC_IEC_559__* +crv-__STDC_ISO10646__ crefvim.txt /*crv-__STDC_ISO10646__* +crv-__STDC_LIMIT_MACROS crefvim.txt /*crv-__STDC_LIMIT_MACROS* +crv-__STDC_VERSION__ crefvim.txt /*crv-__STDC_VERSION__* +crv-__STDC__ crefvim.txt /*crv-__STDC__* +crv-__TIME__ crefvim.txt /*crv-__TIME__* +crv-__bool_true_false_are_defined crefvim.txt /*crv-__bool_true_false_are_defined* +crv-abort crefvim.txt /*crv-abort* +crv-abs crefvim.txt /*crv-abs* +crv-acos crefvim.txt /*crv-acos* +crv-acosf crefvim.txt /*crv-acosf* +crv-acosh crefvim.txt /*crv-acosh* +crv-acoshf crefvim.txt /*crv-acoshf* +crv-acoshl crefvim.txt /*crv-acoshl* +crv-acosl crefvim.txt /*crv-acosl* +crv-asctime crefvim.txt /*crv-asctime* +crv-asin crefvim.txt /*crv-asin* +crv-asinf crefvim.txt /*crv-asinf* +crv-asinh crefvim.txt /*crv-asinh* +crv-asinhf crefvim.txt /*crv-asinhf* +crv-asinhl crefvim.txt /*crv-asinhl* +crv-asinl crefvim.txt /*crv-asinl* +crv-assert crefvim.txt /*crv-assert* +crv-atan crefvim.txt /*crv-atan* +crv-atan2 crefvim.txt /*crv-atan2* +crv-atan2f crefvim.txt /*crv-atan2f* +crv-atan2l crefvim.txt /*crv-atan2l* +crv-atanf crefvim.txt /*crv-atanf* +crv-atanh crefvim.txt /*crv-atanh* +crv-atanhf crefvim.txt /*crv-atanhf* +crv-atanhl crefvim.txt /*crv-atanhl* +crv-atanl crefvim.txt /*crv-atanl* +crv-atexit crefvim.txt /*crv-atexit* +crv-atof crefvim.txt /*crv-atof* +crv-atoi crefvim.txt /*crv-atoi* +crv-atol crefvim.txt /*crv-atol* +crv-atoll crefvim.txt /*crv-atoll* +crv-auto crefvim.txt /*crv-auto* +crv-bibliography crefvim.txt /*crv-bibliography* +crv-bool crefvim.txt /*crv-bool* +crv-break crefvim.txt /*crv-break* +crv-bsearch crefvim.txt /*crv-bsearch* +crv-btowc crefvim.txt /*crv-btowc* +crv-cabs crefvim.txt /*crv-cabs* +crv-cabsf crefvim.txt /*crv-cabsf* +crv-cabsl crefvim.txt /*crv-cabsl* +crv-cacos crefvim.txt /*crv-cacos* +crv-cacosf crefvim.txt /*crv-cacosf* +crv-cacosh crefvim.txt /*crv-cacosh* +crv-cacoshf crefvim.txt /*crv-cacoshf* +crv-cacoshl crefvim.txt /*crv-cacoshl* +crv-cacosl crefvim.txt /*crv-cacosl* +crv-calloc crefvim.txt /*crv-calloc* +crv-carg crefvim.txt /*crv-carg* +crv-cargf crefvim.txt /*crv-cargf* +crv-cargl crefvim.txt /*crv-cargl* +crv-case crefvim.txt /*crv-case* +crv-casin crefvim.txt /*crv-casin* +crv-casinf crefvim.txt /*crv-casinf* +crv-casinh crefvim.txt /*crv-casinh* +crv-casinhf crefvim.txt /*crv-casinhf* +crv-casinhl crefvim.txt /*crv-casinhl* +crv-casinl crefvim.txt /*crv-casinl* +crv-catan crefvim.txt /*crv-catan* +crv-catanf crefvim.txt /*crv-catanf* +crv-catanh crefvim.txt /*crv-catanh* +crv-catanhf crefvim.txt /*crv-catanhf* +crv-catanhl crefvim.txt /*crv-catanhl* +crv-catanl crefvim.txt /*crv-catanl* +crv-cbrt crefvim.txt /*crv-cbrt* +crv-cbrtf crefvim.txt /*crv-cbrtf* +crv-cbrtl crefvim.txt /*crv-cbrtl* +crv-ccos crefvim.txt /*crv-ccos* +crv-ccosf crefvim.txt /*crv-ccosf* +crv-ccosfh crefvim.txt /*crv-ccosfh* +crv-ccosh crefvim.txt /*crv-ccosh* +crv-ccosl crefvim.txt /*crv-ccosl* +crv-ccoslh crefvim.txt /*crv-ccoslh* +crv-ceil crefvim.txt /*crv-ceil* +crv-ceilf crefvim.txt /*crv-ceilf* +crv-ceill crefvim.txt /*crv-ceill* +crv-cexp crefvim.txt /*crv-cexp* +crv-cexpf crefvim.txt /*crv-cexpf* +crv-cexpl crefvim.txt /*crv-cexpl* +crv-char crefvim.txt /*crv-char* +crv-cimag crefvim.txt /*crv-cimag* +crv-cimagf crefvim.txt /*crv-cimagf* +crv-cimagl crefvim.txt /*crv-cimagl* +crv-clearerr crefvim.txt /*crv-clearerr* +crv-clock crefvim.txt /*crv-clock* +crv-clock_t crefvim.txt /*crv-clock_t* +crv-clog crefvim.txt /*crv-clog* +crv-clogf crefvim.txt /*crv-clogf* +crv-clogl crefvim.txt /*crv-clogl* +crv-complex crefvim.txt /*crv-complex* +crv-conj crefvim.txt /*crv-conj* +crv-conjf crefvim.txt /*crv-conjf* +crv-conjl crefvim.txt /*crv-conjl* +crv-const crefvim.txt /*crv-const* +crv-continue crefvim.txt /*crv-continue* +crv-copysign crefvim.txt /*crv-copysign* +crv-copysignf crefvim.txt /*crv-copysignf* +crv-copysignl crefvim.txt /*crv-copysignl* +crv-cos crefvim.txt /*crv-cos* +crv-cosf crefvim.txt /*crv-cosf* +crv-cosh crefvim.txt /*crv-cosh* +crv-coshf crefvim.txt /*crv-coshf* +crv-coshl crefvim.txt /*crv-coshl* +crv-cosl crefvim.txt /*crv-cosl* +crv-cpow crefvim.txt /*crv-cpow* +crv-cpowf crefvim.txt /*crv-cpowf* +crv-cpowl crefvim.txt /*crv-cpowl* +crv-cproj crefvim.txt /*crv-cproj* +crv-cprojf crefvim.txt /*crv-cprojf* +crv-cprojl crefvim.txt /*crv-cprojl* +crv-creal crefvim.txt /*crv-creal* +crv-crealf crefvim.txt /*crv-crealf* +crv-creall crefvim.txt /*crv-creall* +crv-csin crefvim.txt /*crv-csin* +crv-csinf crefvim.txt /*crv-csinf* +crv-csinh crefvim.txt /*crv-csinh* +crv-csinhf crefvim.txt /*crv-csinhf* +crv-csinhl crefvim.txt /*crv-csinhl* +crv-csinl crefvim.txt /*crv-csinl* +crv-csqrt crefvim.txt /*crv-csqrt* +crv-csqrtf crefvim.txt /*crv-csqrtf* +crv-csqrtl crefvim.txt /*crv-csqrtl* +crv-ctan crefvim.txt /*crv-ctan* +crv-ctanf crefvim.txt /*crv-ctanf* +crv-ctanh crefvim.txt /*crv-ctanh* +crv-ctanhf crefvim.txt /*crv-ctanhf* +crv-ctanhl crefvim.txt /*crv-ctanhl* +crv-ctanl crefvim.txt /*crv-ctanl* +crv-ctime crefvim.txt /*crv-ctime* +crv-currency_symbol crefvim.txt /*crv-currency_symbol* +crv-datatypes crefvim.txt /*crv-datatypes* +crv-decimal_point crefvim.txt /*crv-decimal_point* +crv-default crefvim.txt /*crv-default* +crv-defined crefvim.txt /*crv-defined* +crv-dif_t crefvim.txt /*crv-dif_t* +crv-difftime crefvim.txt /*crv-difftime* +crv-div crefvim.txt /*crv-div* +crv-do crefvim.txt /*crv-do* +crv-double crefvim.txt /*crv-double* +crv-dtArrays crefvim.txt /*crv-dtArrays* +crv-dtBitFields crefvim.txt /*crv-dtBitFields* +crv-dtCompleteArrayDecl crefvim.txt /*crv-dtCompleteArrayDecl* +crv-dtConstChar crefvim.txt /*crv-dtConstChar* +crv-dtConstFloat crefvim.txt /*crv-dtConstFloat* +crv-dtConstInt crefvim.txt /*crv-dtConstInt* +crv-dtConstants crefvim.txt /*crv-dtConstants* +crv-dtEnumerate crefvim.txt /*crv-dtEnumerate* +crv-dtFormats crefvim.txt /*crv-dtFormats* +crv-dtFormatsFPBasics crefvim.txt /*crv-dtFormatsFPBasics* +crv-dtFormatsFPDouble crefvim.txt /*crv-dtFormatsFPDouble* +crv-dtFormatsFPFloat crefvim.txt /*crv-dtFormatsFPFloat* +crv-dtFormatsFPInfinity crefvim.txt /*crv-dtFormatsFPInfinity* +crv-dtFormatsFPLDouble crefvim.txt /*crv-dtFormatsFPLDouble* +crv-dtFormatsFPNaN crefvim.txt /*crv-dtFormatsFPNaN* +crv-dtFormatsFPOp crefvim.txt /*crv-dtFormatsFPOp* +crv-dtFormatsFPSDenorm crefvim.txt /*crv-dtFormatsFPSDenorm* +crv-dtFormatsFPTypes crefvim.txt /*crv-dtFormatsFPTypes* +crv-dtFormatsFPValues crefvim.txt /*crv-dtFormatsFPValues* +crv-dtFormatsFPZero crefvim.txt /*crv-dtFormatsFPZero* +crv-dtFormatsFloat crefvim.txt /*crv-dtFormatsFloat* +crv-dtFormatsInt crefvim.txt /*crv-dtFormatsInt* +crv-dtOverview crefvim.txt /*crv-dtOverview* +crv-dtPointers crefvim.txt /*crv-dtPointers* +crv-dtPtrArithmetics crefvim.txt /*crv-dtPtrArithmetics* +crv-dtPtrFuncs crefvim.txt /*crv-dtPtrFuncs* +crv-dtPtrVars crefvim.txt /*crv-dtPtrVars* +crv-dtQualifiers crefvim.txt /*crv-dtQualifiers* +crv-dtSizeRange crefvim.txt /*crv-dtSizeRange* +crv-dtStorageClasses crefvim.txt /*crv-dtStorageClasses* +crv-dtStrings crefvim.txt /*crv-dtStrings* +crv-dtStructAccess crefvim.txt /*crv-dtStructAccess* +crv-dtStructDecl crefvim.txt /*crv-dtStructDecl* +crv-dtStructDef crefvim.txt /*crv-dtStructDef* +crv-dtStructInit crefvim.txt /*crv-dtStructInit* +crv-dtStructurs crefvim.txt /*crv-dtStructurs* +crv-dtTypeCast crefvim.txt /*crv-dtTypeCast* +crv-dtTypeCastExpl crefvim.txt /*crv-dtTypeCastExpl* +crv-dtTypeCastImpl crefvim.txt /*crv-dtTypeCastImpl* +crv-dtTypeDef crefvim.txt /*crv-dtTypeDef* +crv-dtTypeGrouping crefvim.txt /*crv-dtTypeGrouping* +crv-dtTypeSpecifiers crefvim.txt /*crv-dtTypeSpecifiers* +crv-dtUnionAccess crefvim.txt /*crv-dtUnionAccess* +crv-dtUnionDecl crefvim.txt /*crv-dtUnionDecl* +crv-dtUnionDef crefvim.txt /*crv-dtUnionDef* +crv-dtUnionInit crefvim.txt /*crv-dtUnionInit* +crv-dtUnions crefvim.txt /*crv-dtUnions* +crv-dtVoid crefvim.txt /*crv-dtVoid* +crv-else crefvim.txt /*crv-else* +crv-enum crefvim.txt /*crv-enum* +crv-erf crefvim.txt /*crv-erf* +crv-erfc crefvim.txt /*crv-erfc* +crv-erfcf crefvim.txt /*crv-erfcf* +crv-erfcl crefvim.txt /*crv-erfcl* +crv-erff crefvim.txt /*crv-erff* +crv-erfl crefvim.txt /*crv-erfl* +crv-errno crefvim.txt /*crv-errno* +crv-exit crefvim.txt /*crv-exit* +crv-exp crefvim.txt /*crv-exp* +crv-exp2 crefvim.txt /*crv-exp2* +crv-exp2f crefvim.txt /*crv-exp2f* +crv-exp2l crefvim.txt /*crv-exp2l* +crv-expf crefvim.txt /*crv-expf* +crv-expl crefvim.txt /*crv-expl* +crv-expm1 crefvim.txt /*crv-expm1* +crv-expm1f crefvim.txt /*crv-expm1f* +crv-expm1l crefvim.txt /*crv-expm1l* +crv-extern crefvim.txt /*crv-extern* +crv-fabs crefvim.txt /*crv-fabs* +crv-fabsf crefvim.txt /*crv-fabsf* +crv-fabsl crefvim.txt /*crv-fabsl* +crv-false crefvim.txt /*crv-false* +crv-fclose crefvim.txt /*crv-fclose* +crv-fdim crefvim.txt /*crv-fdim* +crv-fdimf crefvim.txt /*crv-fdimf* +crv-fdiml crefvim.txt /*crv-fdiml* +crv-feclearexcept crefvim.txt /*crv-feclearexcept* +crv-fegetenv crefvim.txt /*crv-fegetenv* +crv-fegetexceptflag crefvim.txt /*crv-fegetexceptflag* +crv-fegetround crefvim.txt /*crv-fegetround* +crv-feholdexcept crefvim.txt /*crv-feholdexcept* +crv-fentv_t crefvim.txt /*crv-fentv_t* +crv-feof crefvim.txt /*crv-feof* +crv-feraiseexcept crefvim.txt /*crv-feraiseexcept* +crv-ferror crefvim.txt /*crv-ferror* +crv-fesetenv crefvim.txt /*crv-fesetenv* +crv-fesetexceptflag crefvim.txt /*crv-fesetexceptflag* +crv-fesetround crefvim.txt /*crv-fesetround* +crv-fetestexcept crefvim.txt /*crv-fetestexcept* +crv-feupdateenv crefvim.txt /*crv-feupdateenv* +crv-fflush crefvim.txt /*crv-fflush* +crv-fgetc crefvim.txt /*crv-fgetc* +crv-fgetpos crefvim.txt /*crv-fgetpos* +crv-fgets crefvim.txt /*crv-fgets* +crv-fgetwc crefvim.txt /*crv-fgetwc* +crv-fgetws crefvim.txt /*crv-fgetws* +crv-float crefvim.txt /*crv-float* +crv-floor crefvim.txt /*crv-floor* +crv-floorf crefvim.txt /*crv-floorf* +crv-floorl crefvim.txt /*crv-floorl* +crv-fma crefvim.txt /*crv-fma* +crv-fmaf crefvim.txt /*crv-fmaf* +crv-fmal crefvim.txt /*crv-fmal* +crv-fmax crefvim.txt /*crv-fmax* +crv-fmaxf crefvim.txt /*crv-fmaxf* +crv-fmaxl crefvim.txt /*crv-fmaxl* +crv-fmin crefvim.txt /*crv-fmin* +crv-fminf crefvim.txt /*crv-fminf* +crv-fminl crefvim.txt /*crv-fminl* +crv-fmod crefvim.txt /*crv-fmod* +crv-fmodf crefvim.txt /*crv-fmodf* +crv-fmodl crefvim.txt /*crv-fmodl* +crv-fopen crefvim.txt /*crv-fopen* +crv-for crefvim.txt /*crv-for* +crv-fpclassify crefvim.txt /*crv-fpclassify* +crv-fpos_t crefvim.txt /*crv-fpos_t* +crv-fprintf crefvim.txt /*crv-fprintf* +crv-fputc crefvim.txt /*crv-fputc* +crv-fputs crefvim.txt /*crv-fputs* +crv-fputwc crefvim.txt /*crv-fputwc* +crv-fputws crefvim.txt /*crv-fputws* +crv-frac_digits crefvim.txt /*crv-frac_digits* +crv-fread crefvim.txt /*crv-fread* +crv-free crefvim.txt /*crv-free* +crv-freopen crefvim.txt /*crv-freopen* +crv-frexp crefvim.txt /*crv-frexp* +crv-frexpf crefvim.txt /*crv-frexpf* +crv-frexpl crefvim.txt /*crv-frexpl* +crv-fscanf crefvim.txt /*crv-fscanf* +crv-fseek crefvim.txt /*crv-fseek* +crv-fsetpos crefvim.txt /*crv-fsetpos* +crv-ftell crefvim.txt /*crv-ftell* +crv-fuConversion crefvim.txt /*crv-fuConversion* +crv-fuDefVarPara crefvim.txt /*crv-fuDefVarPara* +crv-fuDefinition crefvim.txt /*crv-fuDefinition* +crv-fuMain crefvim.txt /*crv-fuMain* +crv-fuPrototype crefvim.txt /*crv-fuPrototype* +crv-fuSpecifier crefvim.txt /*crv-fuSpecifier* +crv-fuStorageClasses crefvim.txt /*crv-fuStorageClasses* +crv-functions crefvim.txt /*crv-functions* +crv-fwide crefvim.txt /*crv-fwide* +crv-fwprintf crefvim.txt /*crv-fwprintf* +crv-fwrite crefvim.txt /*crv-fwrite* +crv-fwscanf crefvim.txt /*crv-fwscanf* +crv-getc crefvim.txt /*crv-getc* +crv-getchar crefvim.txt /*crv-getchar* +crv-getenv crefvim.txt /*crv-getenv* +crv-gets crefvim.txt /*crv-gets* +crv-getwc crefvim.txt /*crv-getwc* +crv-getwchar crefvim.txt /*crv-getwchar* +crv-gloAlignment crefvim.txt /*crv-gloAlignment* +crv-gloArgument crefvim.txt /*crv-gloArgument* +crv-gloArray crefvim.txt /*crv-gloArray* +crv-gloBinary crefvim.txt /*crv-gloBinary* +crv-gloBlock crefvim.txt /*crv-gloBlock* +crv-gloCompState crefvim.txt /*crv-gloCompState* +crv-gloDataType crefvim.txt /*crv-gloDataType* +crv-gloDeclaration crefvim.txt /*crv-gloDeclaration* +crv-gloDefinition crefvim.txt /*crv-gloDefinition* +crv-gloExpression crefvim.txt /*crv-gloExpression* +crv-gloIdentifier crefvim.txt /*crv-gloIdentifier* +crv-gloLifetime crefvim.txt /*crv-gloLifetime* +crv-gloLinkage crefvim.txt /*crv-gloLinkage* +crv-gloLvalue crefvim.txt /*crv-gloLvalue* +crv-gloLvalueMod crefvim.txt /*crv-gloLvalueMod* +crv-gloMacro crefvim.txt /*crv-gloMacro* +crv-gloObject crefvim.txt /*crv-gloObject* +crv-gloOpBinary crefvim.txt /*crv-gloOpBinary* +crv-gloOpUnary crefvim.txt /*crv-gloOpUnary* +crv-gloOperand crefvim.txt /*crv-gloOperand* +crv-gloOperator crefvim.txt /*crv-gloOperator* +crv-gloParameter crefvim.txt /*crv-gloParameter* +crv-gloPointer crefvim.txt /*crv-gloPointer* +crv-gloPreprocessor crefvim.txt /*crv-gloPreprocessor* +crv-gloPromote crefvim.txt /*crv-gloPromote* +crv-gloPrototype crefvim.txt /*crv-gloPrototype* +crv-gloRvalue crefvim.txt /*crv-gloRvalue* +crv-gloScope crefvim.txt /*crv-gloScope* +crv-gloSemantics crefvim.txt /*crv-gloSemantics* +crv-gloSideEffect crefvim.txt /*crv-gloSideEffect* +crv-gloSignExtension crefvim.txt /*crv-gloSignExtension* +crv-gloStatement crefvim.txt /*crv-gloStatement* +crv-gloStructure crefvim.txt /*crv-gloStructure* +crv-gloSyntax crefvim.txt /*crv-gloSyntax* +crv-gloToken crefvim.txt /*crv-gloToken* +crv-gloTrueFalse crefvim.txt /*crv-gloTrueFalse* +crv-gloType crefvim.txt /*crv-gloType* +crv-gloTypeCast crefvim.txt /*crv-gloTypeCast* +crv-gloTypeIncomplete crefvim.txt /*crv-gloTypeIncomplete* +crv-gloUnary crefvim.txt /*crv-gloUnary* +crv-gloVariable crefvim.txt /*crv-gloVariable* +crv-gloWhiteSpace crefvim.txt /*crv-gloWhiteSpace* +crv-glossary crefvim.txt /*crv-glossary* +crv-gmtime crefvim.txt /*crv-gmtime* +crv-goto crefvim.txt /*crv-goto* +crv-grouping crefvim.txt /*crv-grouping* +crv-hypot crefvim.txt /*crv-hypot* +crv-hypotf crefvim.txt /*crv-hypotf* +crv-hypotl crefvim.txt /*crv-hypotl* +crv-if crefvim.txt /*crv-if* +crv-ilogb crefvim.txt /*crv-ilogb* +crv-ilogbf crefvim.txt /*crv-ilogbf* +crv-ilogbl crefvim.txt /*crv-ilogbl* +crv-imaginary crefvim.txt /*crv-imaginary* +crv-imaxabs crefvim.txt /*crv-imaxabs* +crv-imaxdiv crefvim.txt /*crv-imaxdiv* +crv-imaxdiv_t crefvim.txt /*crv-imaxdiv_t* +crv-inline crefvim.txt /*crv-inline* +crv-int crefvim.txt /*crv-int* +crv-int16_t crefvim.txt /*crv-int16_t* +crv-int32_t crefvim.txt /*crv-int32_t* +crv-int64_t crefvim.txt /*crv-int64_t* +crv-int8_t crefvim.txt /*crv-int8_t* +crv-int_curr_symbol crefvim.txt /*crv-int_curr_symbol* +crv-int_fast16_t crefvim.txt /*crv-int_fast16_t* +crv-int_fast32_t crefvim.txt /*crv-int_fast32_t* +crv-int_fast64_t crefvim.txt /*crv-int_fast64_t* +crv-int_fast8_t crefvim.txt /*crv-int_fast8_t* +crv-int_frac_digits crefvim.txt /*crv-int_frac_digits* +crv-int_least16_t crefvim.txt /*crv-int_least16_t* +crv-int_least32_t crefvim.txt /*crv-int_least32_t* +crv-int_least64_t crefvim.txt /*crv-int_least64_t* +crv-int_least8_t crefvim.txt /*crv-int_least8_t* +crv-int_n_cs_precedes crefvim.txt /*crv-int_n_cs_precedes* +crv-int_n_sep_by_space crefvim.txt /*crv-int_n_sep_by_space* +crv-int_n_sign_posn crefvim.txt /*crv-int_n_sign_posn* +crv-int_p_cs_precedes crefvim.txt /*crv-int_p_cs_precedes* +crv-int_p_sep_by_space crefvim.txt /*crv-int_p_sep_by_space* +crv-int_p_sign_posn crefvim.txt /*crv-int_p_sign_posn* +crv-intmax_t crefvim.txt /*crv-intmax_t* +crv-intptr_t crefvim.txt /*crv-intptr_t* +crv-intro crefvim.txt /*crv-intro* +crv-isalnum crefvim.txt /*crv-isalnum* +crv-isalpha crefvim.txt /*crv-isalpha* +crv-isblank crefvim.txt /*crv-isblank* +crv-iscntrl crefvim.txt /*crv-iscntrl* +crv-isdigit crefvim.txt /*crv-isdigit* +crv-isfinite crefvim.txt /*crv-isfinite* +crv-isgraph crefvim.txt /*crv-isgraph* +crv-isgreater crefvim.txt /*crv-isgreater* +crv-isgreaterequal crefvim.txt /*crv-isgreaterequal* +crv-isinf crefvim.txt /*crv-isinf* +crv-isless crefvim.txt /*crv-isless* +crv-islessequal crefvim.txt /*crv-islessequal* +crv-islessgreater crefvim.txt /*crv-islessgreater* +crv-islower crefvim.txt /*crv-islower* +crv-isnan crefvim.txt /*crv-isnan* +crv-isnormal crefvim.txt /*crv-isnormal* +crv-isprint crefvim.txt /*crv-isprint* +crv-ispunct crefvim.txt /*crv-ispunct* +crv-isspace crefvim.txt /*crv-isspace* +crv-isunordered crefvim.txt /*crv-isunordered* +crv-isupper crefvim.txt /*crv-isupper* +crv-iswalnum crefvim.txt /*crv-iswalnum* +crv-iswalpha crefvim.txt /*crv-iswalpha* +crv-iswblank crefvim.txt /*crv-iswblank* +crv-iswcntrl crefvim.txt /*crv-iswcntrl* +crv-iswctype crefvim.txt /*crv-iswctype* +crv-iswdigit crefvim.txt /*crv-iswdigit* +crv-iswgraph crefvim.txt /*crv-iswgraph* +crv-iswlower crefvim.txt /*crv-iswlower* +crv-iswprint crefvim.txt /*crv-iswprint* +crv-iswpunct crefvim.txt /*crv-iswpunct* +crv-iswspace crefvim.txt /*crv-iswspace* +crv-iswupper crefvim.txt /*crv-iswupper* +crv-iswxdigit crefvim.txt /*crv-iswxdigit* +crv-isxdigit crefvim.txt /*crv-isxdigit* +crv-jmp_buf crefvim.txt /*crv-jmp_buf* +crv-keywords crefvim.txt /*crv-keywords* +crv-labs crefvim.txt /*crv-labs* +crv-language crefvim.txt /*crv-language* +crv-lconf crefvim.txt /*crv-lconf* +crv-ldexp crefvim.txt /*crv-ldexp* +crv-ldexpf crefvim.txt /*crv-ldexpf* +crv-ldexpl crefvim.txt /*crv-ldexpl* +crv-ldif_t crefvim.txt /*crv-ldif_t* +crv-ldiv crefvim.txt /*crv-ldiv* +crv-lgamma crefvim.txt /*crv-lgamma* +crv-lgammaf crefvim.txt /*crv-lgammaf* +crv-lgammal crefvim.txt /*crv-lgammal* +crv-libAssertH crefvim.txt /*crv-libAssertH* +crv-libCHExpLog crefvim.txt /*crv-libCHExpLog* +crv-libCHHyper crefvim.txt /*crv-libCHHyper* +crv-libCHMac crefvim.txt /*crv-libCHMac* +crv-libCHMani crefvim.txt /*crv-libCHMani* +crv-libCHPower crefvim.txt /*crv-libCHPower* +crv-libCHPrag crefvim.txt /*crv-libCHPrag* +crv-libCHTrig crefvim.txt /*crv-libCHTrig* +crv-libCharHandling crefvim.txt /*crv-libCharHandling* +crv-libCharMapping crefvim.txt /*crv-libCharMapping* +crv-libComplexH crefvim.txt /*crv-libComplexH* +crv-libCtypeH crefvim.txt /*crv-libCtypeH* +crv-libErrnoH crefvim.txt /*crv-libErrnoH* +crv-libFHEnv crefvim.txt /*crv-libFHEnv* +crv-libFHExceptions crefvim.txt /*crv-libFHExceptions* +crv-libFHPrag crefvim.txt /*crv-libFHPrag* +crv-libFHRounding crefvim.txt /*crv-libFHRounding* +crv-libFenvH crefvim.txt /*crv-libFenvH* +crv-libFloatH crefvim.txt /*crv-libFloatH* +crv-libHeaders crefvim.txt /*crv-libHeaders* +crv-libInttypesH crefvim.txt /*crv-libInttypesH* +crv-libIso646H crefvim.txt /*crv-libIso646H* +crv-libLHConv crefvim.txt /*crv-libLHConv* +crv-libLHRange crefvim.txt /*crv-libLHRange* +crv-libLHWidth crefvim.txt /*crv-libLHWidth* +crv-libLimitsH crefvim.txt /*crv-libLimitsH* +crv-libLocHCat crefvim.txt /*crv-libLocHCat* +crv-libLocHFunc crefvim.txt /*crv-libLocHFunc* +crv-libLocHInfo crefvim.txt /*crv-libLocHInfo* +crv-libLocHLoc crefvim.txt /*crv-libLocHLoc* +crv-libLocalH crefvim.txt /*crv-libLocalH* +crv-libMHClass crefvim.txt /*crv-libMHClass* +crv-libMHCmp crefvim.txt /*crv-libMHCmp* +crv-libMHErr crefvim.txt /*crv-libMHErr* +crv-libMHErrGam crefvim.txt /*crv-libMHErrGam* +crv-libMHExpLog crefvim.txt /*crv-libMHExpLog* +crv-libMHHyper crefvim.txt /*crv-libMHHyper* +crv-libMHMani crefvim.txt /*crv-libMHMani* +crv-libMHMisc crefvim.txt /*crv-libMHMisc* +crv-libMHNear crefvim.txt /*crv-libMHNear* +crv-libMHPower crefvim.txt /*crv-libMHPower* +crv-libMHRem crefvim.txt /*crv-libMHRem* +crv-libMHTrig crefvim.txt /*crv-libMHTrig* +crv-libMathH crefvim.txt /*crv-libMathH* +crv-libSHFunc crefvim.txt /*crv-libSHFunc* +crv-libSHSig crefvim.txt /*crv-libSHSig* +crv-libSHTyp crefvim.txt /*crv-libSHTyp* +crv-libSIOHCIO crefvim.txt /*crv-libSIOHCIO* +crv-libSIOHDIO crefvim.txt /*crv-libSIOHDIO* +crv-libSIOHErr crefvim.txt /*crv-libSIOHErr* +crv-libSIOHFAcc crefvim.txt /*crv-libSIOHFAcc* +crv-libSIOHFOp crefvim.txt /*crv-libSIOHFOp* +crv-libSIOHFPos crefvim.txt /*crv-libSIOHFPos* +crv-libSIOHIO crefvim.txt /*crv-libSIOHIO* +crv-libSIOHIOFin crefvim.txt /*crv-libSIOHIOFin* +crv-libSIOHIOFormat crefvim.txt /*crv-libSIOHIOFormat* +crv-libSIOHIOFout crefvim.txt /*crv-libSIOHIOFout* +crv-libSIOHIOFunc crefvim.txt /*crv-libSIOHIOFunc* +crv-libSIOHMac crefvim.txt /*crv-libSIOHMac* +crv-libSIOHStrmFile crefvim.txt /*crv-libSIOHStrmFile* +crv-libSIOHType crefvim.txt /*crv-libSIOHType* +crv-libSLHMac crefvim.txt /*crv-libSLHMac* +crv-libSLHType crefvim.txt /*crv-libSLHType* +crv-libSLHcom crefvim.txt /*crv-libSLHcom* +crv-libSLHintarith crefvim.txt /*crv-libSLHintarith* +crv-libSLHmem crefvim.txt /*crv-libSLHmem* +crv-libSLHmulchar crefvim.txt /*crv-libSLHmulchar* +crv-libSLHmulstrng crefvim.txt /*crv-libSLHmulstrng* +crv-libSLHnum crefvim.txt /*crv-libSLHnum* +crv-libSLHrand crefvim.txt /*crv-libSLHrand* +crv-libSLHsearch crefvim.txt /*crv-libSLHsearch* +crv-libSRHCmp crefvim.txt /*crv-libSRHCmp* +crv-libSRHConcat crefvim.txt /*crv-libSRHConcat* +crv-libSRHCopy crefvim.txt /*crv-libSRHCopy* +crv-libSRHMac crefvim.txt /*crv-libSRHMac* +crv-libSRHMisc crefvim.txt /*crv-libSRHMisc* +crv-libSRHSearch crefvim.txt /*crv-libSRHSearch* +crv-libSRHType crefvim.txt /*crv-libSRHType* +crv-libSdHLExact crefvim.txt /*crv-libSdHLExact* +crv-libSdHLFast crefvim.txt /*crv-libSdHLFast* +crv-libSdHLGreat crefvim.txt /*crv-libSdHLGreat* +crv-libSdHLMin crefvim.txt /*crv-libSdHLMin* +crv-libSdHLOther crefvim.txt /*crv-libSdHLOther* +crv-libSdHLPtr crefvim.txt /*crv-libSdHLPtr* +crv-libSdHMac crefvim.txt /*crv-libSdHMac* +crv-libSdHTExact crefvim.txt /*crv-libSdHTExact* +crv-libSdHTFast crefvim.txt /*crv-libSdHTFast* +crv-libSdHTGreat crefvim.txt /*crv-libSdHTGreat* +crv-libSdHTLim crefvim.txt /*crv-libSdHTLim* +crv-libSdHTMin crefvim.txt /*crv-libSdHTMin* +crv-libSdHTPtr crefvim.txt /*crv-libSdHTPtr* +crv-libSdHType crefvim.txt /*crv-libSdHType* +crv-libSetjmpH crefvim.txt /*crv-libSetjmpH* +crv-libSignalH crefvim.txt /*crv-libSignalH* +crv-libStdargH crefvim.txt /*crv-libStdargH* +crv-libStdboolH crefvim.txt /*crv-libStdboolH* +crv-libStddefH crefvim.txt /*crv-libStddefH* +crv-libStdintH crefvim.txt /*crv-libStdintH* +crv-libStdioH crefvim.txt /*crv-libStdioH* +crv-libStdlibH crefvim.txt /*crv-libStdlibH* +crv-libStringH crefvim.txt /*crv-libStringH* +crv-libTHConv crefvim.txt /*crv-libTHConv* +crv-libTHMac crefvim.txt /*crv-libTHMac* +crv-libTHMani crefvim.txt /*crv-libTHMani* +crv-libTHType crefvim.txt /*crv-libTHType* +crv-libTgmathH crefvim.txt /*crv-libTgmathH* +crv-libTimeH crefvim.txt /*crv-libTimeH* +crv-libWCHCIO crefvim.txt /*crv-libWCHCIO* +crv-libWCHCharConv crefvim.txt /*crv-libWCHCharConv* +crv-libWCHCmp crefvim.txt /*crv-libWCHCmp* +crv-libWCHConcat crefvim.txt /*crv-libWCHConcat* +crv-libWCHCopy crefvim.txt /*crv-libWCHCopy* +crv-libWCHIO crefvim.txt /*crv-libWCHIO* +crv-libWCHMac crefvim.txt /*crv-libWCHMac* +crv-libWCHMisc crefvim.txt /*crv-libWCHMisc* +crv-libWCHNum crefvim.txt /*crv-libWCHNum* +crv-libWCHSearch crefvim.txt /*crv-libWCHSearch* +crv-libWCHStrng crefvim.txt /*crv-libWCHStrng* +crv-libWCHTimeConv crefvim.txt /*crv-libWCHTimeConv* +crv-libWCHType crefvim.txt /*crv-libWCHType* +crv-libWTHCextens crefvim.txt /*crv-libWTHCextens* +crv-libWTHClass crefvim.txt /*crv-libWTHClass* +crv-libWTHCwide crefvim.txt /*crv-libWTHCwide* +crv-libWTHMac crefvim.txt /*crv-libWTHMac* +crv-libWTHMap crefvim.txt /*crv-libWTHMap* +crv-libWTHMextens crefvim.txt /*crv-libWTHMextens* +crv-libWTHMwide crefvim.txt /*crv-libWTHMwide* +crv-libWTHType crefvim.txt /*crv-libWTHType* +crv-libWcharH crefvim.txt /*crv-libWcharH* +crv-libWctypeH crefvim.txt /*crv-libWctypeH* +crv-llabs crefvim.txt /*crv-llabs* +crv-lldif_t crefvim.txt /*crv-lldif_t* +crv-lldiv crefvim.txt /*crv-lldiv* +crv-llrint crefvim.txt /*crv-llrint* +crv-llrintf crefvim.txt /*crv-llrintf* +crv-llrintl crefvim.txt /*crv-llrintl* +crv-llround crefvim.txt /*crv-llround* +crv-llroundf crefvim.txt /*crv-llroundf* +crv-llroundl crefvim.txt /*crv-llroundl* +crv-lngAllowedChar crefvim.txt /*crv-lngAllowedChar* +crv-lngBlockComment crefvim.txt /*crv-lngBlockComment* +crv-lngChar crefvim.txt /*crv-lngChar* +crv-lngComment crefvim.txt /*crv-lngComment* +crv-lngEscSeq crefvim.txt /*crv-lngEscSeq* +crv-lngLineComment crefvim.txt /*crv-lngLineComment* +crv-localeconv crefvim.txt /*crv-localeconv* +crv-localtime crefvim.txt /*crv-localtime* +crv-log crefvim.txt /*crv-log* +crv-log10 crefvim.txt /*crv-log10* +crv-log10f crefvim.txt /*crv-log10f* +crv-log10l crefvim.txt /*crv-log10l* +crv-log1p crefvim.txt /*crv-log1p* +crv-log1pf crefvim.txt /*crv-log1pf* +crv-log1pl crefvim.txt /*crv-log1pl* +crv-log2 crefvim.txt /*crv-log2* +crv-log2f crefvim.txt /*crv-log2f* +crv-log2l crefvim.txt /*crv-log2l* +crv-logb crefvim.txt /*crv-logb* +crv-logbf crefvim.txt /*crv-logbf* +crv-logbl crefvim.txt /*crv-logbl* +crv-logf crefvim.txt /*crv-logf* +crv-logl crefvim.txt /*crv-logl* +crv-long crefvim.txt /*crv-long* +crv-longjmp crefvim.txt /*crv-longjmp* +crv-lrint crefvim.txt /*crv-lrint* +crv-lrintf crefvim.txt /*crv-lrintf* +crv-lrintl crefvim.txt /*crv-lrintl* +crv-lround crefvim.txt /*crv-lround* +crv-lroundf crefvim.txt /*crv-lroundf* +crv-lroundl crefvim.txt /*crv-lroundl* +crv-malloc crefvim.txt /*crv-malloc* +crv-mblen crefvim.txt /*crv-mblen* +crv-mbrlen crefvim.txt /*crv-mbrlen* +crv-mbrtowc crefvim.txt /*crv-mbrtowc* +crv-mbsinit crefvim.txt /*crv-mbsinit* +crv-mbsrtowc crefvim.txt /*crv-mbsrtowc* +crv-mbstate_t crefvim.txt /*crv-mbstate_t* +crv-mbstowcs crefvim.txt /*crv-mbstowcs* +crv-mbtowc crefvim.txt /*crv-mbtowc* +crv-memchr crefvim.txt /*crv-memchr* +crv-memcmp crefvim.txt /*crv-memcmp* +crv-memcpy crefvim.txt /*crv-memcpy* +crv-memmove crefvim.txt /*crv-memmove* +crv-memset crefvim.txt /*crv-memset* +crv-mktime crefvim.txt /*crv-mktime* +crv-modf crefvim.txt /*crv-modf* +crv-modff crefvim.txt /*crv-modff* +crv-modfl crefvim.txt /*crv-modfl* +crv-mon_decimal_point crefvim.txt /*crv-mon_decimal_point* +crv-mon_grouping crefvim.txt /*crv-mon_grouping* +crv-mon_thousands_sep crefvim.txt /*crv-mon_thousands_sep* +crv-n_cs_precedes crefvim.txt /*crv-n_cs_precedes* +crv-n_sep_by_space crefvim.txt /*crv-n_sep_by_space* +crv-n_sign_posn crefvim.txt /*crv-n_sign_posn* +crv-nan crefvim.txt /*crv-nan* +crv-nanf crefvim.txt /*crv-nanf* +crv-nanl crefvim.txt /*crv-nanl* +crv-nearbyint crefvim.txt /*crv-nearbyint* +crv-nearbyintf crefvim.txt /*crv-nearbyintf* +crv-nearbyintl crefvim.txt /*crv-nearbyintl* +crv-negative_sign crefvim.txt /*crv-negative_sign* +crv-nextafter crefvim.txt /*crv-nextafter* +crv-nextafterf crefvim.txt /*crv-nextafterf* +crv-nextafterl crefvim.txt /*crv-nextafterl* +crv-nexttoward crefvim.txt /*crv-nexttoward* +crv-nexttowardf crefvim.txt /*crv-nexttowardf* +crv-nexttowardl crefvim.txt /*crv-nexttowardl* +crv-offsetof crefvim.txt /*crv-offsetof* +crv-onesComplement crefvim.txt /*crv-onesComplement* +crv-opAdd crefvim.txt /*crv-opAdd* +crv-opAddress crefvim.txt /*crv-opAddress* +crv-opArithmetic crefvim.txt /*crv-opArithmetic* +crv-opArraySel crefvim.txt /*crv-opArraySel* +crv-opAsAdd crefvim.txt /*crv-opAsAdd* +crv-opAsAssign crefvim.txt /*crv-opAsAssign* +crv-opAsDiv crefvim.txt /*crv-opAsDiv* +crv-opAsLeftShift crefvim.txt /*crv-opAsLeftShift* +crv-opAsModulo crefvim.txt /*crv-opAsModulo* +crv-opAsMul crefvim.txt /*crv-opAsMul* +crv-opAsSub crefvim.txt /*crv-opAsSub* +crv-opAssigns crefvim.txt /*crv-opAssigns* +crv-opBitAnd crefvim.txt /*crv-opBitAnd* +crv-opBitCompl crefvim.txt /*crv-opBitCompl* +crv-opBitLeftShift crefvim.txt /*crv-opBitLeftShift* +crv-opBitOr crefvim.txt /*crv-opBitOr* +crv-opBitRightShift crefvim.txt /*crv-opBitRightShift* +crv-opBitXor crefvim.txt /*crv-opBitXor* +crv-opBitwise crefvim.txt /*crv-opBitwise* +crv-opConditional crefvim.txt /*crv-opConditional* +crv-opContents crefvim.txt /*crv-opContents* +crv-opDivide crefvim.txt /*crv-opDivide* +crv-opLogAnd crefvim.txt /*crv-opLogAnd* +crv-opLogNot crefvim.txt /*crv-opLogNot* +crv-opLogOr crefvim.txt /*crv-opLogOr* +crv-opLogical crefvim.txt /*crv-opLogical* +crv-opModulo crefvim.txt /*crv-opModulo* +crv-opMultiply crefvim.txt /*crv-opMultiply* +crv-opNegSign crefvim.txt /*crv-opNegSign* +crv-opOthers crefvim.txt /*crv-opOthers* +crv-opOverview crefvim.txt /*crv-opOverview* +crv-opParenth crefvim.txt /*crv-opParenth* +crv-opPosSign crefvim.txt /*crv-opPosSign* +crv-opPostDec crefvim.txt /*crv-opPostDec* +crv-opPostInc crefvim.txt /*crv-opPostInc* +crv-opPreDec crefvim.txt /*crv-opPreDec* +crv-opPrecedence crefvim.txt /*crv-opPrecedence* +crv-opRelEqual crefvim.txt /*crv-opRelEqual* +crv-opRelGT crefvim.txt /*crv-opRelGT* +crv-opRelGTE crefvim.txt /*crv-opRelGTE* +crv-opRelLT crefvim.txt /*crv-opRelLT* +crv-opRelLTE crefvim.txt /*crv-opRelLTE* +crv-opRelUnequal crefvim.txt /*crv-opRelUnequal* +crv-opRelational crefvim.txt /*crv-opRelational* +crv-opSeries crefvim.txt /*crv-opSeries* +crv-opSizeOf crefvim.txt /*crv-opSizeOf* +crv-opStructUnionSel crefvim.txt /*crv-opStructUnionSel* +crv-opSub crefvim.txt /*crv-opSub* +crv-opTypeCast crefvim.txt /*crv-opTypeCast* +crv-operators crefvim.txt /*crv-operators* +crv-p_cs_precedes crefvim.txt /*crv-p_cs_precedes* +crv-p_sep_by_space crefvim.txt /*crv-p_sep_by_space* +crv-p_sign_posn crefvim.txt /*crv-p_sign_posn* +crv-perror crefvim.txt /*crv-perror* +crv-positive_sign crefvim.txt /*crv-positive_sign* +crv-pow crefvim.txt /*crv-pow* +crv-powf crefvim.txt /*crv-powf* +crv-powl crefvim.txt /*crv-powl* +crv-preCondDefined crefvim.txt /*crv-preCondDefined* +crv-preCondElif crefvim.txt /*crv-preCondElif* +crv-preCondElse crefvim.txt /*crv-preCondElse* +crv-preCondEndif crefvim.txt /*crv-preCondEndif* +crv-preCondIf crefvim.txt /*crv-preCondIf* +crv-preCondIfdef crefvim.txt /*crv-preCondIfdef* +crv-preCondIfndef crefvim.txt /*crv-preCondIfndef* +crv-preConditional crefvim.txt /*crv-preConditional* +crv-preError crefvim.txt /*crv-preError* +crv-preLine crefvim.txt /*crv-preLine* +crv-preMac##Operator crefvim.txt /*crv-preMac##Operator* +crv-preMac#Operator crefvim.txt /*crv-preMac#Operator* +crv-preMacCancel crefvim.txt /*crv-preMacCancel* +crv-preMacDef crefvim.txt /*crv-preMacDef* +crv-preMacFunc crefvim.txt /*crv-preMacFunc* +crv-preMacObj crefvim.txt /*crv-preMacObj* +crv-preMacPredefined crefvim.txt /*crv-preMacPredefined* +crv-preMacros crefvim.txt /*crv-preMacros* +crv-preNull crefvim.txt /*crv-preNull* +crv-prePragma crefvim.txt /*crv-prePragma* +crv-preSourceInc crefvim.txt /*crv-preSourceInc* +crv-preprocessor crefvim.txt /*crv-preprocessor* +crv-printf crefvim.txt /*crv-printf* +crv-prtdiff_t crefvim.txt /*crv-prtdiff_t* +crv-punctuators crefvim.txt /*crv-punctuators* +crv-putc crefvim.txt /*crv-putc* +crv-putchar crefvim.txt /*crv-putchar* +crv-puts crefvim.txt /*crv-puts* +crv-putwc crefvim.txt /*crv-putwc* +crv-putwchar crefvim.txt /*crv-putwchar* +crv-qsort crefvim.txt /*crv-qsort* +crv-rais crefvim.txt /*crv-rais* +crv-rand crefvim.txt /*crv-rand* +crv-realloc crefvim.txt /*crv-realloc* +crv-register crefvim.txt /*crv-register* +crv-remainder crefvim.txt /*crv-remainder* +crv-remainderf crefvim.txt /*crv-remainderf* +crv-remainderl crefvim.txt /*crv-remainderl* +crv-remove crefvim.txt /*crv-remove* +crv-remquo crefvim.txt /*crv-remquo* +crv-remquof crefvim.txt /*crv-remquof* +crv-remquol crefvim.txt /*crv-remquol* +crv-rename crefvim.txt /*crv-rename* +crv-restrict crefvim.txt /*crv-restrict* +crv-return crefvim.txt /*crv-return* +crv-rewind crefvim.txt /*crv-rewind* +crv-rint crefvim.txt /*crv-rint* +crv-rintf crefvim.txt /*crv-rintf* +crv-rintl crefvim.txt /*crv-rintl* +crv-round crefvim.txt /*crv-round* +crv-roundf crefvim.txt /*crv-roundf* +crv-roundl crefvim.txt /*crv-roundl* +crv-scalbln crefvim.txt /*crv-scalbln* +crv-scalblnf crefvim.txt /*crv-scalblnf* +crv-scalblnl crefvim.txt /*crv-scalblnl* +crv-scalbn crefvim.txt /*crv-scalbn* +crv-scalbnf crefvim.txt /*crv-scalbnf* +crv-scalbnl crefvim.txt /*crv-scalbnl* +crv-scanf crefvim.txt /*crv-scanf* +crv-setbuf crefvim.txt /*crv-setbuf* +crv-setjmp crefvim.txt /*crv-setjmp* +crv-setlocale crefvim.txt /*crv-setlocale* +crv-setvbuf crefvim.txt /*crv-setvbuf* +crv-short crefvim.txt /*crv-short* +crv-sig_atomic_t crefvim.txt /*crv-sig_atomic_t* +crv-signMagnitude crefvim.txt /*crv-signMagnitude* +crv-signal crefvim.txt /*crv-signal* +crv-signbit crefvim.txt /*crv-signbit* +crv-signed crefvim.txt /*crv-signed* +crv-signgam crefvim.txt /*crv-signgam* +crv-sin crefvim.txt /*crv-sin* +crv-sinf crefvim.txt /*crv-sinf* +crv-sinh crefvim.txt /*crv-sinh* +crv-sinhf crefvim.txt /*crv-sinhf* +crv-sinhl crefvim.txt /*crv-sinhl* +crv-sinl crefvim.txt /*crv-sinl* +crv-size_t crefvim.txt /*crv-size_t* +crv-size_t2 crefvim.txt /*crv-size_t2* +crv-size_t3 crefvim.txt /*crv-size_t3* +crv-size_t4 crefvim.txt /*crv-size_t4* +crv-size_t5 crefvim.txt /*crv-size_t5* +crv-size_t6 crefvim.txt /*crv-size_t6* +crv-sizeof crefvim.txt /*crv-sizeof* +crv-snprintf crefvim.txt /*crv-snprintf* +crv-sprintf crefvim.txt /*crv-sprintf* +crv-sqrt crefvim.txt /*crv-sqrt* +crv-sqrtf crefvim.txt /*crv-sqrtf* +crv-sqrtl crefvim.txt /*crv-sqrtl* +crv-srand crefvim.txt /*crv-srand* +crv-sscanf crefvim.txt /*crv-sscanf* +crv-stBreak crefvim.txt /*crv-stBreak* +crv-stContinue crefvim.txt /*crv-stContinue* +crv-stDoWhile crefvim.txt /*crv-stDoWhile* +crv-stFor crefvim.txt /*crv-stFor* +crv-stGoto crefvim.txt /*crv-stGoto* +crv-stIfElse crefvim.txt /*crv-stIfElse* +crv-stNull crefvim.txt /*crv-stNull* +crv-stReturn crefvim.txt /*crv-stReturn* +crv-stSwitch crefvim.txt /*crv-stSwitch* +crv-stWhile crefvim.txt /*crv-stWhile* +crv-statements crefvim.txt /*crv-statements* +crv-static crefvim.txt /*crv-static* +crv-stdCLib crefvim.txt /*crv-stdCLib* +crv-stderr crefvim.txt /*crv-stderr* +crv-stdin crefvim.txt /*crv-stdin* +crv-stdout crefvim.txt /*crv-stdout* +crv-strcat crefvim.txt /*crv-strcat* +crv-strchr crefvim.txt /*crv-strchr* +crv-strcmp crefvim.txt /*crv-strcmp* +crv-strcoll crefvim.txt /*crv-strcoll* +crv-strcpy crefvim.txt /*crv-strcpy* +crv-strcspn crefvim.txt /*crv-strcspn* +crv-strerror crefvim.txt /*crv-strerror* +crv-strftime crefvim.txt /*crv-strftime* +crv-strlen crefvim.txt /*crv-strlen* +crv-strncat crefvim.txt /*crv-strncat* +crv-strncmp crefvim.txt /*crv-strncmp* +crv-strncpy crefvim.txt /*crv-strncpy* +crv-stroul crefvim.txt /*crv-stroul* +crv-strpbrk crefvim.txt /*crv-strpbrk* +crv-strrchr crefvim.txt /*crv-strrchr* +crv-strspn crefvim.txt /*crv-strspn* +crv-strstr crefvim.txt /*crv-strstr* +crv-strtod crefvim.txt /*crv-strtod* +crv-strtof crefvim.txt /*crv-strtof* +crv-strtoimax crefvim.txt /*crv-strtoimax* +crv-strtok crefvim.txt /*crv-strtok* +crv-strtol crefvim.txt /*crv-strtol* +crv-strtold crefvim.txt /*crv-strtold* +crv-strtoll crefvim.txt /*crv-strtoll* +crv-strtoull crefvim.txt /*crv-strtoull* +crv-strtoumax crefvim.txt /*crv-strtoumax* +crv-struct crefvim.txt /*crv-struct* +crv-strxfrm crefvim.txt /*crv-strxfrm* +crv-switch crefvim.txt /*crv-switch* +crv-swprintf crefvim.txt /*crv-swprintf* +crv-swscanf crefvim.txt /*crv-swscanf* +crv-system crefvim.txt /*crv-system* +crv-tan crefvim.txt /*crv-tan* +crv-tanf crefvim.txt /*crv-tanf* +crv-tanh crefvim.txt /*crv-tanh* +crv-tanhf crefvim.txt /*crv-tanhf* +crv-tanhl crefvim.txt /*crv-tanhl* +crv-tanl crefvim.txt /*crv-tanl* +crv-tgamma crefvim.txt /*crv-tgamma* +crv-tgammaf crefvim.txt /*crv-tgammaf* +crv-tgammal crefvim.txt /*crv-tgammal* +crv-thousands_sep crefvim.txt /*crv-thousands_sep* +crv-time crefvim.txt /*crv-time* +crv-time_t crefvim.txt /*crv-time_t* +crv-tm crefvim.txt /*crv-tm* +crv-tm2 crefvim.txt /*crv-tm2* +crv-tmpfile crefvim.txt /*crv-tmpfile* +crv-tmpnam crefvim.txt /*crv-tmpnam* +crv-tolower crefvim.txt /*crv-tolower* +crv-toupper crefvim.txt /*crv-toupper* +crv-towctrans crefvim.txt /*crv-towctrans* +crv-towlower crefvim.txt /*crv-towlower* +crv-towupper crefvim.txt /*crv-towupper* +crv-trigraph crefvim.txt /*crv-trigraph* +crv-true crefvim.txt /*crv-true* +crv-trunc crefvim.txt /*crv-trunc* +crv-truncf crefvim.txt /*crv-truncf* +crv-truncl crefvim.txt /*crv-truncl* +crv-twosComplement crefvim.txt /*crv-twosComplement* +crv-typedef crefvim.txt /*crv-typedef* +crv-uint16_t crefvim.txt /*crv-uint16_t* +crv-uint32_t crefvim.txt /*crv-uint32_t* +crv-uint64_t crefvim.txt /*crv-uint64_t* +crv-uint8_t crefvim.txt /*crv-uint8_t* +crv-uint_fast16_t crefvim.txt /*crv-uint_fast16_t* +crv-uint_fast32_t crefvim.txt /*crv-uint_fast32_t* +crv-uint_fast64_t crefvim.txt /*crv-uint_fast64_t* +crv-uint_fast8_t crefvim.txt /*crv-uint_fast8_t* +crv-uint_least16_t crefvim.txt /*crv-uint_least16_t* +crv-uint_least32_t crefvim.txt /*crv-uint_least32_t* +crv-uint_least64_t crefvim.txt /*crv-uint_least64_t* +crv-uint_least8_t crefvim.txt /*crv-uint_least8_t* +crv-uintmax_t crefvim.txt /*crv-uintmax_t* +crv-uintptr_t crefvim.txt /*crv-uintptr_t* +crv-ungetc crefvim.txt /*crv-ungetc* +crv-ungetwc crefvim.txt /*crv-ungetwc* +crv-union crefvim.txt /*crv-union* +crv-unsigned crefvim.txt /*crv-unsigned* +crv-va_arg crefvim.txt /*crv-va_arg* +crv-va_copy crefvim.txt /*crv-va_copy* +crv-va_end crefvim.txt /*crv-va_end* +crv-va_list crefvim.txt /*crv-va_list* +crv-va_start crefvim.txt /*crv-va_start* +crv-vfprintf crefvim.txt /*crv-vfprintf* +crv-vfscanf crefvim.txt /*crv-vfscanf* +crv-vfwprintf crefvim.txt /*crv-vfwprintf* +crv-vfwscanf crefvim.txt /*crv-vfwscanf* +crv-void crefvim.txt /*crv-void* +crv-volatile crefvim.txt /*crv-volatile* +crv-vprintf crefvim.txt /*crv-vprintf* +crv-vscanf crefvim.txt /*crv-vscanf* +crv-vsnprintf crefvim.txt /*crv-vsnprintf* +crv-vsprintf crefvim.txt /*crv-vsprintf* +crv-vsscanf crefvim.txt /*crv-vsscanf* +crv-vswprintf crefvim.txt /*crv-vswprintf* +crv-vswscanf crefvim.txt /*crv-vswscanf* +crv-vwprintf crefvim.txt /*crv-vwprintf* +crv-vwscanf crefvim.txt /*crv-vwscanf* +crv-wchar_t crefvim.txt /*crv-wchar_t* +crv-wchar_t2 crefvim.txt /*crv-wchar_t2* +crv-wchar_t3 crefvim.txt /*crv-wchar_t3* +crv-wcrtomb crefvim.txt /*crv-wcrtomb* +crv-wcscat crefvim.txt /*crv-wcscat* +crv-wcschr crefvim.txt /*crv-wcschr* +crv-wcscmp crefvim.txt /*crv-wcscmp* +crv-wcscoll crefvim.txt /*crv-wcscoll* +crv-wcscpy crefvim.txt /*crv-wcscpy* +crv-wcscspn crefvim.txt /*crv-wcscspn* +crv-wcsftime crefvim.txt /*crv-wcsftime* +crv-wcslen crefvim.txt /*crv-wcslen* +crv-wcsncat crefvim.txt /*crv-wcsncat* +crv-wcsncmp crefvim.txt /*crv-wcsncmp* +crv-wcsncpy crefvim.txt /*crv-wcsncpy* +crv-wcspbrk crefvim.txt /*crv-wcspbrk* +crv-wcsrchr crefvim.txt /*crv-wcsrchr* +crv-wcsrtombs crefvim.txt /*crv-wcsrtombs* +crv-wcsspn crefvim.txt /*crv-wcsspn* +crv-wcsstr crefvim.txt /*crv-wcsstr* +crv-wcstod crefvim.txt /*crv-wcstod* +crv-wcstof crefvim.txt /*crv-wcstof* +crv-wcstoimax crefvim.txt /*crv-wcstoimax* +crv-wcstok crefvim.txt /*crv-wcstok* +crv-wcstol crefvim.txt /*crv-wcstol* +crv-wcstold crefvim.txt /*crv-wcstold* +crv-wcstoll crefvim.txt /*crv-wcstoll* +crv-wcstombs crefvim.txt /*crv-wcstombs* +crv-wcstoul crefvim.txt /*crv-wcstoul* +crv-wcstoull crefvim.txt /*crv-wcstoull* +crv-wcstoumax crefvim.txt /*crv-wcstoumax* +crv-wcsxfrm crefvim.txt /*crv-wcsxfrm* +crv-wctob crefvim.txt /*crv-wctob* +crv-wctomb crefvim.txt /*crv-wctomb* +crv-wctrans crefvim.txt /*crv-wctrans* +crv-wctrans_t crefvim.txt /*crv-wctrans_t* +crv-wctype crefvim.txt /*crv-wctype* +crv-wctype_t crefvim.txt /*crv-wctype_t* +crv-while crefvim.txt /*crv-while* +crv-wint_t crefvim.txt /*crv-wint_t* +crv-wint_t2 crefvim.txt /*crv-wint_t2* +crv-wmemchr crefvim.txt /*crv-wmemchr* +crv-wmemcmp crefvim.txt /*crv-wmemcmp* +crv-wmemcpy crefvim.txt /*crv-wmemcpy* +crv-wmemmove crefvim.txt /*crv-wmemmove* +crv-wmemset crefvim.txt /*crv-wmemset* +crv-wprintf crefvim.txt /*crv-wprintf* +crv-wscanf crefvim.txt /*crv-wscanf* +crvdoc-author crefvimdoc.txt /*crvdoc-author* +crvdoc-copyright crefvimdoc.txt /*crvdoc-copyright* +crvdoc-credits crefvimdoc.txt /*crvdoc-credits* +crvdoc-customization crefvimdoc.txt /*crvdoc-customization* +crvdoc-history crefvimdoc.txt /*crvdoc-history* +crvdoc-install crefvimdoc.txt /*crvdoc-install* +crvdoc-intro crefvimdoc.txt /*crvdoc-intro* +crvdoc-lbCRef crefvimdoc.txt /*crvdoc-lbCRef* +crvdoc-lbScript crefvimdoc.txt /*crvdoc-lbScript* +crvdoc-licFDL crefvimdoc.txt /*crvdoc-licFDL* +crvdoc-licFreeDoc crefvimdoc.txt /*crvdoc-licFreeDoc* +crvdoc-licGPL crefvimdoc.txt /*crvdoc-licGPL* +crvdoc-licLGPL crefvimdoc.txt /*crvdoc-licLGPL* +crvdoc-limbugs crefvimdoc.txt /*crvdoc-limbugs* +crvdoc-usage crefvimdoc.txt /*crvdoc-usage* +csupport csupport.txt /*csupport* +csupport-Ctrl-j csupport.txt /*csupport-Ctrl-j* +csupport-ad-mappings csupport.txt /*csupport-ad-mappings* +csupport-c++ csupport.txt /*csupport-c++* +csupport-c++-ex csupport.txt /*csupport-c++-ex* +csupport-c++-method-impl csupport.txt /*csupport-c++-method-impl* +csupport-c++-normal-mode csupport.txt /*csupport-c++-normal-mode* +csupport-c++-visual-mode csupport.txt /*csupport-c++-visual-mode* +csupport-code-to-comm csupport.txt /*csupport-code-to-comm* +csupport-comm csupport.txt /*csupport-comm* +csupport-comm-aligned csupport.txt /*csupport-comm-aligned* +csupport-comm-c-cpp csupport.txt /*csupport-comm-c-cpp* +csupport-comm-date csupport.txt /*csupport-comm-date* +csupport-comm-frame csupport.txt /*csupport-comm-frame* +csupport-comm-keyword csupport.txt /*csupport-comm-keyword* +csupport-comm-realign csupport.txt /*csupport-comm-realign* +csupport-comm-sections csupport.txt /*csupport-comm-sections* +csupport-comm-tags csupport.txt /*csupport-comm-tags* +csupport-comm-to-code csupport.txt /*csupport-comm-to-code* +csupport-ctags csupport.txt /*csupport-ctags* +csupport-ctags-make csupport.txt /*csupport-ctags-make* +csupport-ctags-templates csupport.txt /*csupport-ctags-templates* +csupport-custom csupport.txt /*csupport-custom* +csupport-custom-glob-vars csupport.txt /*csupport-custom-glob-vars* +csupport-custom-root-menu csupport.txt /*csupport-custom-root-menu* +csupport-dictionary csupport.txt /*csupport-dictionary* +csupport-folding csupport.txt /*csupport-folding* +csupport-help csupport.txt /*csupport-help* +csupport-hotkeys csupport.txt /*csupport-hotkeys* +csupport-idioms csupport.txt /*csupport-idioms* +csupport-idioms-for-loop csupport.txt /*csupport-idioms-for-loop* +csupport-idioms-function csupport.txt /*csupport-idioms-function* +csupport-idioms-input csupport.txt /*csupport-idioms-input* +csupport-idioms-output csupport.txt /*csupport-idioms-output* +csupport-prep csupport.txt /*csupport-prep* +csupport-prep-ex csupport.txt /*csupport-prep-ex* +csupport-prep-if0 csupport.txt /*csupport-prep-if0* +csupport-prep-normal-mode csupport.txt /*csupport-prep-normal-mode* +csupport-prep-visual-mode csupport.txt /*csupport-prep-visual-mode* +csupport-proto csupport.txt /*csupport-proto* +csupport-release-notes csupport.txt /*csupport-release-notes* +csupport-run csupport.txt /*csupport-run* +csupport-run-buffer csupport.txt /*csupport-run-buffer* +csupport-run-cmdline-args csupport.txt /*csupport-run-cmdline-args* +csupport-run-codecheck csupport.txt /*csupport-run-codecheck* +csupport-run-hardcopy csupport.txt /*csupport-run-hardcopy* +csupport-run-indent csupport.txt /*csupport-run-indent* +csupport-run-make csupport.txt /*csupport-run-make* +csupport-run-make-args csupport.txt /*csupport-run-make-args* +csupport-run-output csupport.txt /*csupport-run-output* +csupport-run-splint csupport.txt /*csupport-run-splint* +csupport-run-templates csupport.txt /*csupport-run-templates* +csupport-run-xterm csupport.txt /*csupport-run-xterm* +csupport-snippets csupport.txt /*csupport-snippets* +csupport-stat csupport.txt /*csupport-stat* +csupport-stat-normal-mode csupport.txt /*csupport-stat-normal-mode* +csupport-stat-visual-mode csupport.txt /*csupport-stat-visual-mode* +csupport-system-wide csupport.txt /*csupport-system-wide* +csupport-templates csupport.txt /*csupport-templates* +csupport-templates-bind csupport.txt /*csupport-templates-bind* +csupport-templates-date csupport.txt /*csupport-templates-date* +csupport-templates-definition csupport.txt /*csupport-templates-definition* +csupport-templates-expansion csupport.txt /*csupport-templates-expansion* +csupport-templates-files csupport.txt /*csupport-templates-files* +csupport-templates-jump csupport.txt /*csupport-templates-jump* +csupport-templates-macros csupport.txt /*csupport-templates-macros* +csupport-templates-menu csupport.txt /*csupport-templates-menu* +csupport-templates-names csupport.txt /*csupport-templates-names* +csupport-templates-sets csupport.txt /*csupport-templates-sets* +csupport-tips csupport.txt /*csupport-tips* +csupport-troubleshooting csupport.txt /*csupport-troubleshooting* +csupport-usage-gvim csupport.txt /*csupport-usage-gvim* +csupport-usage-vim csupport.txt /*csupport-usage-vim* +csupport-windows csupport.txt /*csupport-windows* +csupport.txt csupport.txt /*csupport.txt* +drv-dtArrayInit crefvim.txt /*drv-dtArrayInit* +drv-dtIncompleteArrayDecl crefvim.txt /*drv-dtIncompleteArrayDecl* +g:cecscope_dboptions cecscope.txt /*g:cecscope_dboptions* +omnicpp-download omnicppcomplete.txt /*omnicpp-download* +omnicpp-faq omnicppcomplete.txt /*omnicpp-faq* +omnicpp-features omnicppcomplete.txt /*omnicpp-features* +omnicpp-history omnicppcomplete.txt /*omnicpp-history* +omnicpp-installation omnicppcomplete.txt /*omnicpp-installation* +omnicpp-limitations omnicppcomplete.txt /*omnicpp-limitations* +omnicpp-may-complete omnicppcomplete.txt /*omnicpp-may-complete* +omnicpp-options omnicppcomplete.txt /*omnicpp-options* +omnicpp-overview omnicppcomplete.txt /*omnicpp-overview* +omnicpp-popup omnicppcomplete.txt /*omnicpp-popup* +omnicpp-thanks omnicppcomplete.txt /*omnicpp-thanks* +omnicppcomplete omnicppcomplete.txt /*omnicppcomplete* +omnicppcomplete.txt omnicppcomplete.txt /*omnicppcomplete.txt* +op-opAsRightShift crefvim.txt /*op-opAsRightShift* +opAsBitAnd crefvim.txt /*opAsBitAnd* +opAsBitOr crefvim.txt /*opAsBitOr* +opAsBitXor crefvim.txt /*opAsBitXor* +treeExplDirSort vtreeexplorer.txt /*treeExplDirSort* +treeExplHidden vtreeexplorer.txt /*treeExplHidden* +treeExplHidePattern vtreeexplorer.txt /*treeExplHidePattern* +treeExplIndent vtreeexplorer.txt /*treeExplIndent* +treeExplVertical vtreeexplorer.txt /*treeExplVertical* +treeExplWinSize vtreeexplorer.txt /*treeExplWinSize* +vtreeexplorer vtreeexplorer.txt /*vtreeexplorer* +vtreeexplorer-? vtreeexplorer.txt /*vtreeexplorer-?* +vtreeexplorer-C vtreeexplorer.txt /*vtreeexplorer-C* +vtreeexplorer-CD vtreeexplorer.txt /*vtreeexplorer-CD* +vtreeexplorer-D vtreeexplorer.txt /*vtreeexplorer-D* +vtreeexplorer-E vtreeexplorer.txt /*vtreeexplorer-E* +vtreeexplorer-H vtreeexplorer.txt /*vtreeexplorer-H* +vtreeexplorer-O vtreeexplorer.txt /*vtreeexplorer-O* +vtreeexplorer-R vtreeexplorer.txt /*vtreeexplorer-R* +vtreeexplorer-S vtreeexplorer.txt /*vtreeexplorer-S* +vtreeexplorer-X vtreeexplorer.txt /*vtreeexplorer-X* +vtreeexplorer-Yank vtreeexplorer.txt /*vtreeexplorer-Yank* +vtreeexplorer-a vtreeexplorer.txt /*vtreeexplorer-a* +vtreeexplorer-commands vtreeexplorer.txt /*vtreeexplorer-commands* +vtreeexplorer-config vtreeexplorer.txt /*vtreeexplorer-config* +vtreeexplorer-contents vtreeexplorer.txt /*vtreeexplorer-contents* +vtreeexplorer-cursordir vtreeexplorer.txt /*vtreeexplorer-cursordir* +vtreeexplorer-enter vtreeexplorer.txt /*vtreeexplorer-enter* +vtreeexplorer-install vtreeexplorer.txt /*vtreeexplorer-install* +vtreeexplorer-mappings vtreeexplorer.txt /*vtreeexplorer-mappings* +vtreeexplorer-o vtreeexplorer.txt /*vtreeexplorer-o* +vtreeexplorer-p vtreeexplorer.txt /*vtreeexplorer-p* +vtreeexplorer-r vtreeexplorer.txt /*vtreeexplorer-r* +vtreeexplorer-t vtreeexplorer.txt /*vtreeexplorer-t* +vtreeexplorer-terms vtreeexplorer.txt /*vtreeexplorer-terms* +vtreeexplorer-topdir vtreeexplorer.txt /*vtreeexplorer-topdir* +vtreeexplorer-u vtreeexplorer.txt /*vtreeexplorer-u* +vtreeexplorer.txt vtreeexplorer.txt /*vtreeexplorer.txt* diff --git a/.vim/doc/vtreeexplorer.txt b/.vim/doc/vtreeexplorer.txt new file mode 100644 index 0000000..7893323 --- /dev/null +++ b/.vim/doc/vtreeexplorer.txt @@ -0,0 +1,226 @@ +*vtreeexplorer.txt* Vim Tree Explorer Dec 28, 2007 + +Authors: T. Scott Urban <thomas.scott.urban@HORMELgmail.com> + + (remove the source of SPAM from my email first) + +0. DESCRIPTION *vtreeexplorer* + +This plugin creates a tree based file explorer within vim. The tree view is +similar to the output of the unix 'tree' command, with the addition that +directories are foldable and the tree is lazy loaded as you navigate the tree. +The tree is highlighted and several mapping are created for navigation and +opening files from the tree. + +============================================================================== +1. CONTENTS *vtreeexplorer-contents* + + 0. DESCRIPTION ..................: |vtreeexplorer| + 1. CONTENTS......................: |vtreeexplorer-contents| + 2. VTREEEXPLORER INSTALLATION ...: |vtreeexplorer-install| + 3. VTREEEXPLORER CONFIGURATION ..: |vtreeexplorer-config| + 4. VTREEEXPLORER TERMS ..........: |vtreeexplorer-terms| + 5. VTREEEXPLORER MAPPINGS .......: |vtreeexplorer-mapping| + '<enter>' ..................: |vtreeexplorer-enter| + 'o' ........................: |vtreeexplorer-o| + 'o' ........................: |vtreeexplorer-O| + 't' ........................: |vtreeexplorer-t| + 'X' ........................: |vtreeexplorer-X| + 'E' ........................: |vtreeexplorer-E| + 'C' ........................: |vtreeexplorer-C| + 'H' ........................: |vtreeexplorer-H| + 'u' ........................: |vtreeexplorer-u| + 'p' ........................: |vtreeexplorer-p| + 'r' ........................: |vtreeexplorer-r| + 'R' ........................: |vtreeexplorer-R| + 'S' ........................: |vtreeexplorer-S| + 'D' ........................: |vtreeexplorer-D| + 'a' ........................: |vtreeexplorer-a| + '?' ........................: |vtreeexplorer-?| + 6. VTREEEXPLORER COMMANDS .......: |vtreeexplorer-commands| + :CD ........................: |vtreeexplorer-CD| + :Yank ......................: |vtreeexplorer-Yank| + +============================================================================== +2. VTREEEXPLORER INSTALLATION *vtreeexplorer-install* + +To install, un-gzip and un-tar in your $HOME/.vim or $VIMRUNTIME directory, or +the equivalent for the OS you are using. To add this documentation to the +searchable help index, do ":helptags ~/.vim/doc" or equivalent. + +============================================================================== +3. VTREEEXPLORER CONFIGURATION *vtreeexplorer-config* + +There are four global variables that affect vtreeexplorer on startup. These +variables only affect the initial behavior after using |VTreeExplore| or +|VSTreeExplore| to start the tree explorer. Setting these variables after the +start of the tree explorer with those commands will have no affect on +currently running tree explorers. Settings can be changed with the +commands/functions/mappings in running tree explorers. This allows for the +creation of mutliple tree explorer windows with different settings. The +global variables affecting tree explorer startup are: + +treeExplVertical *treeExplVertical* + +Set this variable in your vimrc to use a vertical split when using the +splitting version of the explorer |VSTreeExplore|. + +treeExplWinSize *treeExplWinSize* + +Set this variable to a number in your vimrc to control the windows size (width +or height, depending on |treeExplVertical| when using the splitting version of +the explorer |VSTreeExplore|. + +treeExplHidden *treeExplHidden* + +Set this variable in your vimrc to start the exlorer with hidden files shown. +Otherwise, the explorer will be started with hidden files (start with '.' for +Unix) not shown. + +This setting can be be toggled with the 'a' mapping (|vtreeexplorer-a|). + +treeExplHidePattern *treeExplHidePattern* + +Set this variable to a regular expression to avoid showing matching files and +directories when the hidden option is set (in addition to hidden 'dotfiles'). +This variable can be changed at anytime and it will be reflected in the next +refresh or directory load. + +treeExplDirSort *treeExplDirSort* + +Set this variable in your vimrc to start the explorer with the desired +directory sorting. Possible values: + + 0 : no directory sorting + 1 : directories sorted first + -1 : directories sorted last + +This setting can be switched with the 'D' mapping (|vtreeexplorer-D|. + +treeExplIndent *treeExplIndent* + +This variable is used on initialization to determine the width of the tree +structures drawn at the left of the browser. The default value is 3 which +yields a more compact view. A value of 4 will emulate the old behavior. the +maximum and minimum values for this setting are 2 and 8, respectively. + +treeExplNoList treeExplNoList + +This variable is used on initialization to tell the TreeExplorer not to list +itself in the buffer list. Use of this setting prevents restore of the +explorer with sessions. + +============================================================================== +4. VTREEEXPLORER TERMS *vtreeexplorer-terms* + +The following terms are defined for brevity in the remainder of the +documentation: + +cursordir *vtreeexplorer-cursordir* + +This term refers to the directory where the cursor is in the explorer. If the +cursor is on a line with a directory, that is the cursordir. If the cursor is +on a file, then the cursor dir is the parent directory of the file on the +cursor line. + +topdir *vtreeexplorer-topdir* + +This term refers to the directory where the tree explorerer is rooted - that +is, the top-most directory shown in the tree. + +============================================================================== +5. VTREEEXPLORER MAPPINGS *vtreeexplorer-mappings* + +'<enter>' *vtreeexplorer-enter* + +Same as |vtreeexplorer-o| below. + +'o' *vtreeexplorer-o* + +If the cursor is on a line with a file, open that file in another window. The +last window visitied is where the file will be opened, unless the previous +window contains an unmodified buffer or there is only one window, in which +case a new window will be opened for the file. + +If the cursor is on a line with a directory, load the directory if it isn't +loaded, or toggle the fold for that directory, if the directory is loaded. + +'O' *vtreeexplorer-O* + +Same as |vtreeexplorer-o| but use use the explorer window when opening the +file (closing the explorer). + +'t' *vtreeexplorer-t* + +Same as |vtreeexplorer-o| but use new tab instead window when opening the file. + +'X' *vtreeexplorer-X* + +Recursively expand the |vtreeexplorer-cursordir|. + +'E' *vtreeexplorer-E* + +Open the standard vim |file-explorer| on the |vtreeexplorer-cursordir|. + +'C' *vtreeexplorer-C* + +Change the |vtreeexplorer-topdir| to the |vtreeexplorer-cursordir|. + +'H' *vtreeexplorer-H* + +Change the |vtreeexplorer-topdir| to your home directory, defined by the +environement variable $HOME. + +'u' *vtreeexplorer-u* + +Change the |vtreeexplorer-topdir| up one level, to the parent directory of the +current topdir. + +'p' *vtreeexplorer-p* + +Move the cursor to the parent directory of the |vtreeexplorer-cursordir|. +Hitting 'p' mutliple times will quickly take you to the top of the tree. + +'r' *vtreeexplorer-r* + +Refresh the |vtreeexplorer-cursordir|. This command might unload +subdirectories of the cursordir, depending on current expansion. + +'R' *vtreeexplorer-R* + +Refresh the |vtreeexplorer-topdir|.This command might unload subdirectories of +the cursordir, depending on current expansion. + +'S' *vtreeexplorer-S* + +Start a shell in the |vtreeexplorer-cursordir|. + +'D' *vtreeexplorer-D* + +Switch between the three directory sorting modes, described at +|treeExplDirSort|. Initial value can be set with global variable +|treeExplDirSort|. + +'a' *vtreeexplorer-a* + +Toggle showing hidden files. Initial value can be set with global variable +|treeExplHidden|. Hidden files are those starting with a dot or those defined +by the regular expression in the variable |treeExplHidePattern|. + +'?' *vtreeexplorer-?* + +Toggle long help display at top of window. + +============================================================================== +5. VTREEEXPLORER COMMANDS *vtreeexplorer-commands* + +:CD *vtreeexplorer-CD* + +Change |vtreeexplorer-topdir| to argument of command. + +:Yank *vtreeexplorer-Yank* + +Yank selection of tree with foldmarkers stripped from register. + +vim:tw=78:ts=8:ft=help + diff --git a/.vim/ftplugin/c.vim b/.vim/ftplugin/c.vim new file mode 100644 index 0000000..1a4b473 --- /dev/null +++ b/.vim/ftplugin/c.vim @@ -0,0 +1,436 @@ +" ------------------------------------------------------------------------------ +" +" Vim filetype plugin file +" +" Language : C / C++ +" Plugin : c.vim +" Maintainer : Fritz Mehner <mehner@fh-swf.de> +" Revision : $Id: c.vim,v 1.57 2010/02/05 13:21:11 mehner Exp $ +" +" ------------------------------------------------------------------------------ +" +" Only do this when not done yet for this buffer +" +if exists("b:did_C_ftplugin") + finish +endif +let b:did_C_ftplugin = 1 +" +" ---------- Do we have a mapleader other than '\' ? ------------ +" +if exists("g:C_MapLeader") + let maplocalleader = g:C_MapLeader +endif +" +" ---------- C/C++ dictionary ----------------------------------- +" This will enable keyword completion for C and C++ +" using Vim's dictionary feature |i_CTRL-X_CTRL-K|. +" Set the new dictionaries in front of the existing ones +" +if exists("g:C_Dictionary_File") + let save=&dictionary + silent! exe 'setlocal dictionary='.g:C_Dictionary_File + silent! exe 'setlocal dictionary+='.save +endif +" +" ---------- F-key mappings ------------------------------------ +" +" Alt-F9 write buffer and compile +" F9 compile and link +" Ctrl-F9 run executable +" Shift-F9 command line arguments +" + map <buffer> <silent> <A-F9> :call C_Compile()<CR>:call C_HlMessage()<CR> +imap <buffer> <silent> <A-F9> <C-C>:call C_Compile()<CR>:call C_HlMessage()<CR> +" + map <buffer> <silent> <F9> :call C_Link()<CR>:call C_HlMessage()<CR> +imap <buffer> <silent> <F9> <C-C>:call C_Link()<CR>:call C_HlMessage()<CR> +" + map <buffer> <silent> <C-F9> :call C_Run()<CR> +imap <buffer> <silent> <C-F9> <C-C>:call C_Run()<CR> +" + map <buffer> <silent> <S-F9> :call C_Arguments()<CR> +imap <buffer> <silent> <S-F9> <C-C>:call C_Arguments()<CR> +" +" ---------- alternate file plugin (a.vim) ---------------------- +" +if exists("loaded_alternateFile") + map <buffer> <silent> <S-F2> :A<CR> +imap <buffer> <silent> <S-F2> <C-C>:A<CR> +endif +" +command! -nargs=1 -complete=customlist,C_CFileSectionList CFileSection call C_CFileSectionListInsert (<f-args>) +command! -nargs=1 -complete=customlist,C_HFileSectionList HFileSection call C_HFileSectionListInsert (<f-args>) +command! -nargs=1 -complete=customlist,C_KeywordCommentList KeywordComment call C_KeywordCommentListInsert (<f-args>) +command! -nargs=1 -complete=customlist,C_SpecialCommentList SpecialComment call C_SpecialCommentListInsert (<f-args>) +command! -nargs=1 -complete=customlist,C_StdLibraryIncludesList IncludeStdLibrary call C_StdLibraryIncludesInsert (<f-args>) +command! -nargs=1 -complete=customlist,C_C99LibraryIncludesList IncludeC99Library call C_C99LibraryIncludesInsert (<f-args>) +command! -nargs=1 -complete=customlist,C_CppLibraryIncludesList IncludeCppLibrary call C_CppLibraryIncludesInsert (<f-args>) +command! -nargs=1 -complete=customlist,C_CppCLibraryIncludesList IncludeCppCLibrary call C_CppCLibraryIncludesInsert(<f-args>) +command! -nargs=1 -complete=customlist,C_StyleList CStyle call C_Style (<f-args>) + +" ---------- KEY MAPPINGS : MENU ENTRIES ------------------------------------- +" ---------- comments menu ------------------------------------------------ +" + noremap <buffer> <silent> <LocalLeader>cl :call C_LineEndComment()<CR> +inoremap <buffer> <silent> <LocalLeader>cl <Esc>:call C_LineEndComment()<CR> +vnoremap <buffer> <silent> <LocalLeader>cl <Esc>:call C_MultiLineEndComments()<CR>a + noremap <buffer> <silent> <LocalLeader>cj :call C_AdjustLineEndComm("a")<CR> +vnoremap <buffer> <silent> <LocalLeader>cj <Esc>:call C_AdjustLineEndComm("v")<CR> +inoremap <buffer> <silent> <LocalLeader>cj <Esc>:call C_AdjustLineEndComm("a")<CR>a + noremap <buffer> <silent> <LocalLeader>cs :call C_GetLineEndCommCol()<CR> + + noremap <buffer> <silent> <LocalLeader>c* :call C_CodeComment("a","yes")<CR>:nohlsearch<CR>j +vnoremap <buffer> <silent> <LocalLeader>c* <Esc>:call C_CodeComment("v","yes")<CR>:nohlsearch<CR>j + + noremap <buffer> <silent> <LocalLeader>cc :call C_CodeComment("a","no")<CR>:nohlsearch<CR>j +vnoremap <buffer> <silent> <LocalLeader>cc <Esc>:call C_CodeComment("v","no")<CR>:nohlsearch<CR>j + noremap <buffer> <silent> <LocalLeader>co :call C_CommentCode("a")<CR>:nohlsearch<CR> +vnoremap <buffer> <silent> <LocalLeader>co <Esc>:call C_CommentCode("v")<CR>:nohlsearch<CR> + + noremap <buffer> <silent> <LocalLeader>cfr :call C_InsertTemplate("comment.frame")<CR> + noremap <buffer> <silent> <LocalLeader>cfu :call C_InsertTemplate("comment.function")<CR> + noremap <buffer> <silent> <LocalLeader>cme :call C_InsertTemplate("comment.method")<CR> + noremap <buffer> <silent> <LocalLeader>ccl :call C_InsertTemplate("comment.class")<CR> + noremap <buffer> <silent> <LocalLeader>cfdi :call C_InsertTemplate("comment.file-description")<CR> + noremap <buffer> <silent> <LocalLeader>cfdh :call C_InsertTemplate("comment.file-description-header")<CR> + +inoremap <buffer> <silent> <LocalLeader>cfr <Esc>:call C_InsertTemplate("comment.frame")<CR> +inoremap <buffer> <silent> <LocalLeader>cfu <Esc>:call C_InsertTemplate("comment.function")<CR> +inoremap <buffer> <silent> <LocalLeader>cme <Esc>:call C_InsertTemplate("comment.method")<CR> +inoremap <buffer> <silent> <LocalLeader>ccl <Esc>:call C_InsertTemplate("comment.class")<CR> +inoremap <buffer> <silent> <LocalLeader>cfdi <Esc>:call C_InsertTemplate("comment.file-description")<CR> +inoremap <buffer> <silent> <LocalLeader>cfdh <Esc>:call C_InsertTemplate("comment.file-description-header")<CR> + + noremap <buffer> <silent> <LocalLeader>cd <Esc>:call C_InsertDateAndTime('d')<CR> +inoremap <buffer> <silent> <LocalLeader>cd <Esc>:call C_InsertDateAndTime('d')<CR>a +vnoremap <buffer> <silent> <LocalLeader>cd s<Esc>:call C_InsertDateAndTime('d')<CR>a + noremap <buffer> <silent> <LocalLeader>ct <Esc>:call C_InsertDateAndTime('dt')<CR> +inoremap <buffer> <silent> <LocalLeader>ct <Esc>:call C_InsertDateAndTime('dt')<CR>a +vnoremap <buffer> <silent> <LocalLeader>ct s<Esc>:call C_InsertDateAndTime('dt')<CR>a +" +" call the above defined commands: +" + noremap <buffer> <LocalLeader>ccs <Esc>:CFileSection<Space> + noremap <buffer> <LocalLeader>chs <Esc>:HFileSection<Space> + noremap <buffer> <LocalLeader>ckc <Esc>:KeywordComment<Space> + noremap <buffer> <LocalLeader>csc <Esc>:SpecialComment<Space> +" +inoremap <buffer> <LocalLeader>ccs <Esc>:CFileSection<Space> +inoremap <buffer> <LocalLeader>chs <Esc>:HFileSection<Space> +inoremap <buffer> <LocalLeader>ckc <Esc>:KeywordComment<Space> +inoremap <buffer> <LocalLeader>csc <Esc>:SpecialComment<Space> +" +" ---------- statements menu ------------------------------------------------ +" + noremap <buffer> <silent> <LocalLeader>sd :call C_InsertTemplate("statements.do-while")<CR> +vnoremap <buffer> <silent> <LocalLeader>sd <Esc>:call C_InsertTemplate("statements.do-while", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>sd <Esc>:call C_InsertTemplate("statements.do-while")<CR> + + noremap <buffer> <silent> <LocalLeader>sf :call C_InsertTemplate("statements.for")<CR> +inoremap <buffer> <silent> <LocalLeader>sf <Esc>:call C_InsertTemplate("statements.for")<CR> + + noremap <buffer> <silent> <LocalLeader>sfo :call C_InsertTemplate("statements.for-block")<CR> +vnoremap <buffer> <silent> <LocalLeader>sfo <Esc>:call C_InsertTemplate("statements.for-block", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>sfo <Esc>:call C_InsertTemplate("statements.for-block")<CR> + + noremap <buffer> <silent> <LocalLeader>si :call C_InsertTemplate("statements.if")<CR> +inoremap <buffer> <silent> <LocalLeader>si <Esc>:call C_InsertTemplate("statements.if")<CR> + + noremap <buffer> <silent> <LocalLeader>sif :call C_InsertTemplate("statements.if-block")<CR> +vnoremap <buffer> <silent> <LocalLeader>sif <Esc>:call C_InsertTemplate("statements.if-block", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>sif <Esc>:call C_InsertTemplate("statements.if-block")<CR> + + noremap <buffer> <silent> <LocalLeader>sie :call C_InsertTemplate("statements.if-else")<CR> +vnoremap <buffer> <silent> <LocalLeader>sie <Esc>:call C_InsertTemplate("statements.if-else", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>sie <Esc>:call C_InsertTemplate("statements.if-else")<CR> + + noremap <buffer> <silent> <LocalLeader>sife :call C_InsertTemplate("statements.if-block-else")<CR> +vnoremap <buffer> <silent> <LocalLeader>sife <Esc>:call C_InsertTemplate("statements.if-block-else", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>sife <Esc>:call C_InsertTemplate("statements.if-block-else")<CR> + + noremap <buffer> <silent> <LocalLeader>se :call C_InsertTemplate("statements.else-block")<CR> +vnoremap <buffer> <silent> <LocalLeader>se <Esc>:call C_InsertTemplate("statements.else-block", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>se <Esc>:call C_InsertTemplate("statements.else-block")<CR> + + noremap <buffer> <silent> <LocalLeader>sw :call C_InsertTemplate("statements.while")<CR> +inoremap <buffer> <silent> <LocalLeader>sw <Esc>:call C_InsertTemplate("statements.while")<CR> + + noremap <buffer> <silent> <LocalLeader>swh :call C_InsertTemplate("statements.while-block")<CR> +vnoremap <buffer> <silent> <LocalLeader>swh <Esc>:call C_InsertTemplate("statements.while-block", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>swh <Esc>:call C_InsertTemplate("statements.while-block")<CR> + + noremap <buffer> <silent> <LocalLeader>ss :call C_InsertTemplate("statements.switch")<CR> +vnoremap <buffer> <silent> <LocalLeader>ss <Esc>:call C_InsertTemplate("statements.switch", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>ss <Esc>:call C_InsertTemplate("statements.switch")<CR> + + noremap <buffer> <silent> <LocalLeader>sc :call C_InsertTemplate("statements.case")<CR> +inoremap <buffer> <silent> <LocalLeader>sc <Esc>:call C_InsertTemplate("statements.case")<CR> + + noremap <buffer> <silent> <LocalLeader>s{ :call C_InsertTemplate("statements.block")<CR> +vnoremap <buffer> <silent> <LocalLeader>s{ <Esc>:call C_InsertTemplate("statements.block", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>s{ <Esc>:call C_InsertTemplate("statements.block")<CR> + + noremap <buffer> <silent> <LocalLeader>sb :call C_InsertTemplate("statements.block")<CR> +vnoremap <buffer> <silent> <LocalLeader>sb <Esc>:call C_InsertTemplate("statements.block", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>sb <Esc>:call C_InsertTemplate("statements.block")<CR> +" +" ---------- preprocessor menu ---------------------------------------------- +"" + noremap <buffer> <LocalLeader>ps :IncludeStdLibrary<Space> +inoremap <buffer> <LocalLeader>ps <Esc>:IncludeStdLibrary<Space> + noremap <buffer> <LocalLeader>pc :IncludeC99Library<Space> +inoremap <buffer> <LocalLeader>pc <Esc>:IncludeC99Library<Space> + noremap <buffer> <LocalLeader>+ps :IncludeCppLibrary<Space> +inoremap <buffer> <LocalLeader>+ps <Esc>:IncludeCppLibrary<Space> + noremap <buffer> <LocalLeader>+pc :IncludeCppCLibrary<Space> +inoremap <buffer> <LocalLeader>+pc <Esc>:IncludeCppC9Library<Space> +" + noremap <buffer> <silent> <LocalLeader>p< :call C_InsertTemplate("preprocessor.include-global")<CR> + noremap <buffer> <silent> <LocalLeader>p" :call C_InsertTemplate("preprocessor.include-local")<CR> + noremap <buffer> <silent> <LocalLeader>pd :call C_InsertTemplate("preprocessor.define")<CR> + noremap <buffer> <silent> <LocalLeader>pu :call C_InsertTemplate("preprocessor.undefine")<CR> +" +inoremap <buffer> <silent> <LocalLeader>p< <Esc>:call C_InsertTemplate("preprocessor.include-global")<CR> +inoremap <buffer> <silent> <LocalLeader>p" <Esc>:call C_InsertTemplate("preprocessor.include-local")<CR> +inoremap <buffer> <silent> <LocalLeader>pd <Esc>:call C_InsertTemplate("preprocessor.define")<CR> +inoremap <buffer> <silent> <LocalLeader>pu <Esc>:call C_InsertTemplate("preprocessor.undefine")<CR> + + noremap <buffer> <silent> <LocalLeader>pie :call C_InsertTemplate("preprocessor.if-else-endif")<CR> + noremap <buffer> <silent> <LocalLeader>pid :call C_InsertTemplate("preprocessor.ifdef-else-endif")<CR> + noremap <buffer> <silent> <LocalLeader>pin :call C_InsertTemplate("preprocessor.ifndef-else-endif")<CR> + noremap <buffer> <silent> <LocalLeader>pind :call C_InsertTemplate("preprocessor.ifndef-def-endif")<CR> + +vnoremap <buffer> <silent> <LocalLeader>pie <Esc>:call C_InsertTemplate("preprocessor.if-else-endif", "v")<CR> +vnoremap <buffer> <silent> <LocalLeader>pid <Esc>:call C_InsertTemplate("preprocessor.ifdef-else-endif", "v")<CR> +vnoremap <buffer> <silent> <LocalLeader>pin <Esc>:call C_InsertTemplate("preprocessor.ifndef-else-endif", "v")<CR> +vnoremap <buffer> <silent> <LocalLeader>pind <Esc>:call C_InsertTemplate("preprocessor.ifndef-def-endif", "v")<CR> + +inoremap <buffer> <silent> <LocalLeader>pie <Esc>:call C_InsertTemplate("preprocessor.if-else-endif")<CR> +inoremap <buffer> <silent> <LocalLeader>pid <Esc>:call C_InsertTemplate("preprocessor.ifdef-else-endif")<CR> +inoremap <buffer> <silent> <LocalLeader>pin <Esc>:call C_InsertTemplate("preprocessor.ifndef-else-endif")<CR> +inoremap <buffer> <silent> <LocalLeader>pind <Esc>:call C_InsertTemplate("preprocessor.ifndef-def-endif")<CR> + + noremap <buffer> <silent> <LocalLeader>pi0 :call C_PPIf0("a")<CR>2ji +inoremap <buffer> <silent> <LocalLeader>pi0 <Esc>:call C_PPIf0("a")<CR>2ji +vnoremap <buffer> <silent> <LocalLeader>pi0 <Esc>:call C_PPIf0("v")<CR> + + noremap <buffer> <silent> <LocalLeader>pr0 :call C_PPIf0Remove()<CR> +inoremap <buffer> <silent> <LocalLeader>pr0 <Esc>:call C_PPIf0Remove()<CR> +" + noremap <buffer> <silent> <LocalLeader>pe :call C_InsertTemplate("preprocessor.error")<CR> + noremap <buffer> <silent> <LocalLeader>pl :call C_InsertTemplate("preprocessor.line")<CR> + noremap <buffer> <silent> <LocalLeader>pp :call C_InsertTemplate("preprocessor.pragma")<CR> +" +inoremap <buffer> <silent> <LocalLeader>pe <Esc>:call C_InsertTemplate("preprocessor.error")<CR> +inoremap <buffer> <silent> <LocalLeader>pl <Esc>:call C_InsertTemplate("preprocessor.line")<CR> +inoremap <buffer> <silent> <LocalLeader>pp <Esc>:call C_InsertTemplate("preprocessor.pragma")<CR> +" +" ---------- idioms menu ---------------------------------------------------- +" + noremap <buffer> <silent> <LocalLeader>if :call C_InsertTemplate("idioms.function")<CR> +vnoremap <buffer> <silent> <LocalLeader>if <Esc>:call C_InsertTemplate("idioms.function", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>if <Esc>:call C_InsertTemplate("idioms.function")<CR> + noremap <buffer> <silent> <LocalLeader>isf :call C_InsertTemplate("idioms.function-static")<CR> +vnoremap <buffer> <silent> <LocalLeader>isf <Esc>:call C_InsertTemplate("idioms.function-static", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>isf <Esc>:call C_InsertTemplate("idioms.function-static")<CR> + noremap <buffer> <silent> <LocalLeader>im :call C_InsertTemplate("idioms.main")<CR> +vnoremap <buffer> <silent> <LocalLeader>im <Esc>:call C_InsertTemplate("idioms.main", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>im <Esc>:call C_InsertTemplate("idioms.main")<CR> +" + noremap <buffer> <silent> <LocalLeader>i0 :call C_CodeFor("up" , "a")<CR> +vnoremap <buffer> <silent> <LocalLeader>i0 <Esc>:call C_CodeFor("up" , "v")<CR> +inoremap <buffer> <silent> <LocalLeader>i0 <Esc>:call C_CodeFor("up" , "a")<CR>i + noremap <buffer> <silent> <LocalLeader>in :call C_CodeFor("down", "a")<CR> +vnoremap <buffer> <silent> <LocalLeader>in <Esc>:call C_CodeFor("down", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>in <Esc>:call C_CodeFor("down", "a")<CR>i +" + noremap <buffer> <silent> <LocalLeader>ie :call C_InsertTemplate("idioms.enum")<CR> +vnoremap <buffer> <silent> <LocalLeader>ie <Esc>:call C_InsertTemplate("idioms.enum" , "v")<CR> +inoremap <buffer> <silent> <LocalLeader>ie <Esc>:call C_InsertTemplate("idioms.enum")<CR> + noremap <buffer> <silent> <LocalLeader>is :call C_InsertTemplate("idioms.struct")<CR> +vnoremap <buffer> <silent> <LocalLeader>is <Esc>:call C_InsertTemplate("idioms.struct", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>is <Esc>:call C_InsertTemplate("idioms.struct")<CR> + noremap <buffer> <silent> <LocalLeader>iu :call C_InsertTemplate("idioms.union")<CR> +vnoremap <buffer> <silent> <LocalLeader>iu <Esc>:call C_InsertTemplate("idioms.union" , "v")<CR> +inoremap <buffer> <silent> <LocalLeader>iu <Esc>:call C_InsertTemplate("idioms.union")<CR> +" + noremap <buffer> <silent> <LocalLeader>ip :call C_InsertTemplate("idioms.printf")<CR> +inoremap <buffer> <silent> <LocalLeader>ip <Esc>:call C_InsertTemplate("idioms.printf")<CR> + noremap <buffer> <silent> <LocalLeader>isc :call C_InsertTemplate("idioms.scanf")<CR> +inoremap <buffer> <silent> <LocalLeader>isc <Esc>:call C_InsertTemplate("idioms.scanf")<CR> +" + noremap <buffer> <silent> <LocalLeader>ica :call C_InsertTemplate("idioms.calloc")<CR> +inoremap <buffer> <silent> <LocalLeader>ica <Esc>:call C_InsertTemplate("idioms.calloc")<CR> + noremap <buffer> <silent> <LocalLeader>ima :call C_InsertTemplate("idioms.malloc")<CR> +inoremap <buffer> <silent> <LocalLeader>ima <Esc>:call C_InsertTemplate("idioms.malloc")<CR> +" + noremap <buffer> <silent> <LocalLeader>isi :call C_InsertTemplate("idioms.sizeof")<CR> +inoremap <buffer> <silent> <LocalLeader>isi <Esc>:call C_InsertTemplate("idioms.sizeof")<CR> +vnoremap <buffer> <silent> <LocalLeader>isi <Esc>:call C_InsertTemplate("idioms.sizeof", "v")<CR> + + noremap <buffer> <silent> <LocalLeader>ias :call C_InsertTemplate("idioms.assert")<CR> +vnoremap <buffer> <silent> <LocalLeader>ias <Esc>:call C_InsertTemplate("idioms.assert", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>ias <Esc>:call C_InsertTemplate("idioms.assert")<CR> +" + noremap <buffer> <silent> <LocalLeader>ii :call C_InsertTemplate("idioms.open-input-file")<CR> +inoremap <buffer> <silent> <LocalLeader>ii <Esc>:call C_InsertTemplate("idioms.open-input-file")<CR> +vnoremap <buffer> <silent> <LocalLeader>ii <Esc>:call C_InsertTemplate("idioms.open-input-file", "v")<CR> + noremap <buffer> <silent> <LocalLeader>io :call C_InsertTemplate("idioms.open-output-file")<CR> +inoremap <buffer> <silent> <LocalLeader>io <Esc>:call C_InsertTemplate("idioms.open-output-file")<CR> +vnoremap <buffer> <silent> <LocalLeader>io <Esc>:call C_InsertTemplate("idioms.open-output-file", "v")<CR> +" +" ---------- snippet menu ---------------------------------------------------- +" + noremap <buffer> <silent> <LocalLeader>nr :call C_CodeSnippet("r")<CR> + noremap <buffer> <silent> <LocalLeader>nw :call C_CodeSnippet("w")<CR> +vnoremap <buffer> <silent> <LocalLeader>nw <Esc>:call C_CodeSnippet("wv")<CR> + noremap <buffer> <silent> <LocalLeader>ne :call C_CodeSnippet("e")<CR> +" +inoremap <buffer> <silent> <LocalLeader>nr <Esc>:call C_CodeSnippet("r")<CR> +inoremap <buffer> <silent> <LocalLeader>nw <Esc>:call C_CodeSnippet("w")<CR> +inoremap <buffer> <silent> <LocalLeader>ne <Esc>:call C_CodeSnippet("e")<CR> +" + noremap <buffer> <silent> <LocalLeader>np :call C_ProtoPick("n")<CR> +vnoremap <buffer> <silent> <LocalLeader>np <Esc>:call C_ProtoPick("v")<CR> + noremap <buffer> <silent> <LocalLeader>ni :call C_ProtoInsert()<CR> + noremap <buffer> <silent> <LocalLeader>nc :call C_ProtoClear()<CR> + noremap <buffer> <silent> <LocalLeader>ns :call C_ProtoShow()<CR> +" +inoremap <buffer> <silent> <LocalLeader>np <Esc>:call C_ProtoPick("n")<CR> +inoremap <buffer> <silent> <LocalLeader>ni <Esc>:call C_ProtoInsert()<CR> +inoremap <buffer> <silent> <LocalLeader>nc <Esc>:call C_ProtoClear()<CR> +inoremap <buffer> <silent> <LocalLeader>ns <Esc>:call C_ProtoShow()<CR> +" + noremap <buffer> <silent> <LocalLeader>ntl :call C_EditTemplates("local")<CR> + noremap <buffer> <silent> <LocalLeader>ntg :call C_EditTemplates("global")<CR> + noremap <buffer> <silent> <LocalLeader>ntr :call C_RereadTemplates()<CR> + noremap <buffer> <LocalLeader>nts <Esc>:CStyle<Space> +" +" ---------- C++ menu ---------------------------------------------------- +" + noremap <buffer> <silent> <LocalLeader>+co :call C_InsertTemplate("cpp.cout")<CR> +inoremap <buffer> <silent> <LocalLeader>+co <Esc>:call C_InsertTemplate("cpp.cout")<CR> +" + noremap <buffer> <silent> <LocalLeader>+c :call C_InsertTemplate("cpp.class-definition")<CR> +inoremap <buffer> <silent> <LocalLeader>+c <Esc>:call C_InsertTemplate("cpp.class-definition")<CR> + noremap <buffer> <silent> <LocalLeader>+cn :call C_InsertTemplate("cpp.class-using-new-definition")<CR> +inoremap <buffer> <silent> <LocalLeader>+cn <Esc>:call C_InsertTemplate("cpp.class-using-new-definition")<CR> + + noremap <buffer> <silent> <LocalLeader>+ci :call C_InsertTemplate("cpp.class-implementation")<CR> +inoremap <buffer> <silent> <LocalLeader>+ci <Esc>:call C_InsertTemplate("cpp.class-implementation")<CR> + noremap <buffer> <silent> <LocalLeader>+cni :call C_InsertTemplate("cpp.class-using-new-implementation")<CR> +inoremap <buffer> <silent> <LocalLeader>+cni <Esc>:call C_InsertTemplate("cpp.class-using-new-implementation")<CR> + + noremap <buffer> <silent> <LocalLeader>+mi :call C_InsertTemplate("cpp.method-implementation")<CR> +inoremap <buffer> <silent> <LocalLeader>+mi <Esc>:call C_InsertTemplate("cpp.method-implementation")<CR> + noremap <buffer> <silent> <LocalLeader>+ai :call C_InsertTemplate("cpp.accessor-implementation")<CR> +inoremap <buffer> <silent> <LocalLeader>+ai <Esc>:call C_InsertTemplate("cpp.accessor-implementation")<CR> + + noremap <buffer> <silent> <LocalLeader>+tc :call C_InsertTemplate("cpp.template-class-definition")<CR> +inoremap <buffer> <silent> <LocalLeader>+tc <Esc>:call C_InsertTemplate("cpp.template-class-definition")<CR> + noremap <buffer> <silent> <LocalLeader>+tcn :call C_InsertTemplate("cpp.template-class-using-new-definition")<CR> +inoremap <buffer> <silent> <LocalLeader>+tcn <Esc>:call C_InsertTemplate("cpp.template-class-using-new-definition")<CR> + + noremap <buffer> <silent> <LocalLeader>+tci :call C_InsertTemplate("cpp.template-class-implementation")<CR> +inoremap <buffer> <silent> <LocalLeader>+tci <Esc>:call C_InsertTemplate("cpp.template-class-implementation")<CR> + noremap <buffer> <silent> <LocalLeader>+tcni :call C_InsertTemplate("cpp.template-class-using-new-implementation")<CR> +inoremap <buffer> <silent> <LocalLeader>+tcni <Esc>:call C_InsertTemplate("cpp.template-class-using-new-implementation")<CR> + + noremap <buffer> <silent> <LocalLeader>+tmi :call C_InsertTemplate("cpp.template-method-implementation")<CR> +inoremap <buffer> <silent> <LocalLeader>+tmi <Esc>:call C_InsertTemplate("cpp.template-method-implementation")<CR> + noremap <buffer> <silent> <LocalLeader>+tai :call C_InsertTemplate("cpp.template-accessor-implementation")<CR> +inoremap <buffer> <silent> <LocalLeader>+tai <Esc>:call C_InsertTemplate("cpp.template-accessor-implementation")<CR> + + noremap <buffer> <silent> <LocalLeader>+tf :call C_InsertTemplate("cpp.template-function")<CR> +inoremap <buffer> <silent> <LocalLeader>+tf <Esc>:call C_InsertTemplate("cpp.template-function")<CR> + + noremap <buffer> <silent> <LocalLeader>+ec :call C_InsertTemplate("cpp.error-class")<CR> +inoremap <buffer> <silent> <LocalLeader>+ec <Esc>:call C_InsertTemplate("cpp.error-class")<CR> + + noremap <buffer> <silent> <LocalLeader>+tr :call C_InsertTemplate("cpp.try-catch")<CR> +vnoremap <buffer> <silent> <LocalLeader>+tr <Esc>:call C_InsertTemplate("cpp.try-catch", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>+tr <Esc>:call C_InsertTemplate("cpp.try-catch")<CR> + + noremap <buffer> <silent> <LocalLeader>+ca :call C_InsertTemplate("cpp.catch")<CR> +vnoremap <buffer> <silent> <LocalLeader>+ca <Esc>:call C_InsertTemplate("cpp.catch", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>+ca <Esc>:call C_InsertTemplate("cpp.catch")<CR> + + noremap <buffer> <silent> <LocalLeader>+c. :call C_InsertTemplate("cpp.catch-points")<CR> +vnoremap <buffer> <silent> <LocalLeader>+c. <Esc>:call C_InsertTemplate("cpp.catch-points", "v")<CR> +inoremap <buffer> <silent> <LocalLeader>+c. <Esc>:call C_InsertTemplate("cpp.catch-points")<CR> +" +" ---------- run menu -------------------------------------------------------- +" + map <buffer> <silent> <LocalLeader>rc :call C_Compile()<CR>:call C_HlMessage()<CR> + map <buffer> <silent> <LocalLeader>rl :call C_Link()<CR>:call C_HlMessage()<CR> + map <buffer> <silent> <LocalLeader>rr :call C_Run()<CR> + map <buffer> <silent> <LocalLeader>ra :call C_Arguments()<CR> + map <buffer> <silent> <LocalLeader>rm :call C_Make()<CR> + map <buffer> <silent> <LocalLeader>rg :call C_MakeArguments()<CR> + map <buffer> <silent> <LocalLeader>rp :call C_SplintCheck()<CR>:call C_HlMessage()<CR> + map <buffer> <silent> <LocalLeader>ri :call C_SplintArguments()<CR> + map <buffer> <silent> <LocalLeader>rd :call C_Indent()<CR> + map <buffer> <silent> <LocalLeader>rh :call C_Hardcopy("n")<CR> + map <buffer> <silent> <LocalLeader>rs :call C_Settings()<CR> +" +vmap <buffer> <silent> <LocalLeader>rh <C-C>:call C_Hardcopy("v")<CR> +" +imap <buffer> <silent> <LocalLeader>rc <C-C>:call C_Compile()<CR>:call C_HlMessage()<CR> +imap <buffer> <silent> <LocalLeader>rl <C-C>:call C_Link()<CR>:call C_HlMessage()<CR> +imap <buffer> <silent> <LocalLeader>rr <C-C>:call C_Run()<CR> +imap <buffer> <silent> <LocalLeader>ra <C-C>:call C_Arguments()<CR> +imap <buffer> <silent> <LocalLeader>rm <C-C>:call C_Make()<CR> +imap <buffer> <silent> <LocalLeader>rg <C-C>:call C_MakeArguments()<CR> +imap <buffer> <silent> <LocalLeader>rp <C-C>:call C_SplintCheck()<CR>:call C_HlMessage()<CR> +imap <buffer> <silent> <LocalLeader>ri <C-C>:call C_SplintArguments()<CR> +imap <buffer> <silent> <LocalLeader>rd <C-C>:call C_Indent()<CR> +imap <buffer> <silent> <LocalLeader>rh <C-C>:call C_Hardcopy("n")<CR> +imap <buffer> <silent> <LocalLeader>rs <C-C>:call C_Settings()<CR> + if has("unix") + map <buffer> <silent> <LocalLeader>rx :call C_XtermSize()<CR> + imap <buffer> <silent> <LocalLeader>rx <C-C>:call C_XtermSize()<CR> + endif + map <buffer> <silent> <LocalLeader>ro :call C_Toggle_Gvim_Xterm()<CR> +imap <buffer> <silent> <LocalLeader>ro <C-C>:call C_Toggle_Gvim_Xterm()<CR> +" +" Abraxas CodeCheck (R) +" +if executable("check") + map <buffer> <silent> <LocalLeader>rk :call C_CodeCheck()<CR>:call C_HlMessage()<CR> + map <buffer> <silent> <LocalLeader>re :call C_CodeCheckArguments()<CR> + imap <buffer> <silent> <LocalLeader>rk <C-C>:call C_CodeCheck()<CR>:call C_HlMessage()<CR> + imap <buffer> <silent> <LocalLeader>re <C-C>:call C_CodeCheckArguments()<CR> +endif +" ---------- plugin help ----------------------------------------------------- +" + map <buffer> <silent> <LocalLeader>hp :call C_HelpCsupport()<CR> +imap <buffer> <silent> <LocalLeader>hp <C-C>:call C_HelpCsupport()<CR> + map <buffer> <silent> <LocalLeader>hm :call C_Help("m")<CR> +imap <buffer> <silent> <LocalLeader>hm <C-C>:call C_Help("m")<CR> +" +"------------------------------------------------------------------------------- +" additional mapping : complete a classical C comment: '/*' => '/* | */' +"------------------------------------------------------------------------------- +inoremap <buffer> /* /*<Space><Space>*/<Left><Left><Left> +vnoremap <buffer> /* s/*<Space><Space>*/<Left><Left><Left><Esc>p +" +"------------------------------------------------------------------------------- +" additional mapping : complete a classical C multi-line comment: +" '/*<CR>' => /* +" * | +" */ +"------------------------------------------------------------------------------- +inoremap <buffer> /*<CR> /*<CR><CR>/<Esc>kA<Space> +" +"------------------------------------------------------------------------------- +" additional mapping : {<CR> always opens a block +"------------------------------------------------------------------------------- +inoremap <buffer> {<CR> {<CR>}<Esc>O +vnoremap <buffer> {<CR> S{<CR>}<Esc>Pk=iB +" +" +if !exists("g:C_Ctrl_j") || ( exists("g:C_Ctrl_j") && g:C_Ctrl_j != 'off' ) + nmap <buffer> <silent> <C-j> i<C-R>=C_JumpCtrlJ()<CR> + imap <buffer> <silent> <C-j> <C-R>=C_JumpCtrlJ()<CR> +endif diff --git a/.vim/plugin/buftabs.vim b/.vim/plugin/buftabs.vim new file mode 100644 index 0000000..30edea9 --- /dev/null +++ b/.vim/plugin/buftabs.vim @@ -0,0 +1,309 @@ +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" buftabs (C) 2006 Ico Doornekamp +" +" This program is free software; you can redistribute it and/or modify it +" under the terms of the GNU General Public License as published by the Free +" Software Foundation; either version 2 of the License, or (at your option) +" any later version. +" +" This program is distributed in the hope that it will be useful, but WITHOUT +" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +" more details. +" +" Introduction +" ------------ +" +" This is a simple script that shows a tabs-like list of buffers in the bottom +" of the window. The biggest advantage of this script over various others is +" that it does not take any lines away from your terminal, leaving more space +" for the document you're editing. The tabs are only visible when you need +" them - when you are switchin between buffers. +" +" Usage +" ----- +" +" This script draws buffer tabs on vim startup, when a new buffer is created +" and when switching between buffers. +" +" It might be handy to create a few maps for easy switching of buffers in your +" .vimrc file. For example, using F1 and F2 keys: +" +" noremap <f1> :bprev<CR> +" noremap <f2> :bnext<CR> +" +" or using control-left and control-right keys: +" +" :noremap <C-left> :bprev<CR> +" :noremap <C-right> :bnext<CR> +" +" +" The following extra configuration variables are availabe: +" +" * g:buftabs_only_basename +" +" Define this variable to make buftabs only print the filename of each buffer, +" omitting the preceding directory name. Add to your .vimrc: +" +" :let g:buftabs_only_basename=1 +" +" +" * g:buftabs_in_statusline +" +" Define this variable to make the plugin show the buftabs in the statusline +" instead of the command line. It is a good idea to configure vim to show +" the statusline as well when only one window is open. Add to your .vimrc: +" +" set laststatus=2 +" :let g:buftabs_in_statusline=1 +" +" +" * g:buftabs_active_highlight_group +" * g:buftabs_inactive_highlight_group +" +" The name of a highlight group (:help highligh-groups) which is used to +" show the name of the current active buffer and of all other inactive +" buffers. If these variables are not defined, no highlighting is used. +" (Highlighting is only functional when g:buftabs_in_statusline is enabled) +" +" :let g:buftabs_active_highlight_group="Visual" +" +" +" * g:buftabs_marker_start [ +" * g:buftabs_marker_end ] +" * g:buftabs_separator - +" +" These strings are drawn around each tab as separators. +" +" :let g:buftabs_separator = "." +" :let g:buftabs_marker_start = "(" +" :let g:buftabs_marker_end = ")" +" +" +" Changelog +" --------- +" +" 0.1 2006-09-22 Initial version +" +" 0.2 2006-09-22 Better handling when the list of buffers is longer then the +" window width. +" +" 0.3 2006-09-27 Some cleanups, set 'hidden' mode by default +" +" 0.4 2007-02-26 Don't draw buftabs until VimEnter event to avoid clutter at +" startup in some circumstances +" +" 0.5 2007-02-26 Added option for showing only filenames without directories +" in tabs +" +" 0.6 2007-03-04 'only_basename' changed to a global variable. Removed +" functions and add event handlers instead. 'hidden' mode +" broke some things, so is disabled now. Fixed documentation +" +" 0.7 2007-03-07 Added configuration option to show tabs in statusline +" instead of cmdline +" +" 0.8 2007-04-02 Update buftabs when leaving insertmode +" +" 0.9 2007-08-22 Now compatible with older Vim versions < 7.0 +" +" 0.10 2008-01-26 Added GPL license +" +" 0.11 2008-02-29 Added optional syntax highlighting to active buffer name +" +" 0.12 2009-03-18 Fixed support for split windows +" +" 0.13 2009-05-07 Store and reuse right-aligned part of original statusline +" +" 0.14 2010-01-28 Fixed bug that caused buftabs in command line being +" overwritten when 'hidden' mode is enabled. +" +" 0.15 2010-02-16 Fixed window width handling bug which caused strange +" behaviour in combination with the bufferlist plugin. +" Fixed wrong buffer display when deleting last window. +" Added extra options for tabs style and highlighting. +" +" 0.16 2010-02-28 Fixed bug causing errors when using buftabs in vim +" diff mode. +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +let w:buftabs_enabled = 0 +let w:original_statusline = matchstr(&statusline, "%=.*") + +" +" Don't bother when in diff mode +" + +if &diff + finish +endif + + +" +" Called on VimEnter event +" + +function! Buftabs_enable() + let w:buftabs_enabled = 1 +endfunction + + +" +" Persistent echo to avoid overwriting of status line when 'hidden' is enabled +" + +function! Pecho(msg) + let s:hold_ut=&ut|let &ut=1 + let s:Pecho=a:msg + aug Pecho + au CursorHold * ec s:Pecho + \|let &ut=s:hold_ut + \|aug Pecho|exe 'au!'|aug END|aug! Pecho + aug END +endf + + +" +" Draw the buftabs +" + +function! Buftabs_show(deleted_buf) + + let l:i = 1 + let l:list = '' + let l:start = 0 + let l:end = 0 + if ! exists("w:from") + let w:from = 0 + endif + + if ! exists("w:buftabs_enabled") + return + endif + + " Walk the list of buffers + + while(l:i <= bufnr('$')) + + " Only show buffers in the list, and omit help screens + + if buflisted(l:i) && getbufvar(l:i, "&modifiable") && a:deleted_buf != l:i + + " Get the name of the current buffer, and escape characters that might + " mess up the statusline + + if exists("g:buftabs_only_basename") + let l:name = fnamemodify(bufname(l:i), ":t") + else + let l:name = bufname(l:i) + endif + let l:name = substitute(l:name, "%", "%%", "g") + + " Append the current buffer number and name to the list. If the buffer + " is the active buffer, enclose it in some magick characters which will + " be replaced by markers later. If it is modified, it is appended with + " an exclaimation mark + + if winbufnr(winnr()) == l:i + let l:start = strlen(l:list) + let l:list = l:list . "\x01" + else + let l:list = l:list . ' ' + endif + + let l:buftabs_separator = "-" + if exists("g:buftabs_separator") + let l:buftabs_separator = g:buftabs_separator + endif + + let l:list = l:list . l:i . l:buftabs_separator + let l:list = l:list . l:name + + if getbufvar(l:i, "&modified") == 1 + let l:list = l:list . "!" + endif + + if winbufnr(winnr()) == l:i + let l:list = l:list . "\x02" + let l:end = strlen(l:list) + else + let l:list = l:list . ' ' + endif + end + + let l:i = l:i + 1 + endwhile + + " If the resulting list is too long to fit on the screen, chop + " out the appropriate part + + let l:width = winwidth(0) - 12 + + if(l:start < w:from) + let w:from = l:start - 1 + endif + if l:end > w:from + l:width + let w:from = l:end - l:width + endif + + let l:list = strpart(l:list, w:from, l:width) + + " Replace the magic characters by visible markers for highlighting the + " current buffer. The markers can be simple characters like square brackets, + " but can also be special codes with highlight groups + + let l:buftabs_marker_start = "[" + if exists("g:buftabs_marker_start") + let l:buftabs_marker_start = g:buftabs_marker_start + endif + + let l:buftabs_marker_end = "]" + if exists("g:buftabs_marker_end") + let l:buftabs_marker_end = g:buftabs_marker_end + endif + + if exists("g:buftabs_active_highlight_group") + if exists("g:buftabs_in_statusline") + let l:buftabs_marker_start = "%#" . g:buftabs_active_highlight_group . "#" . l:buftabs_marker_start + let l:buftabs_marker_end = l:buftabs_marker_end . "%##" + end + end + + if exists("g:buftabs_inactive_highlight_group") + if exists("g:buftabs_in_statusline") + let l:list = '%#' . g:buftabs_inactive_highlight_group . '#' . l:list + let l:list .= '%##' + let l:buftabs_marker_end = l:buftabs_marker_end . '%#' . g:buftabs_inactive_highlight_group . '#' + end + end + + let l:list = substitute(l:list, "\x01", l:buftabs_marker_start, 'g') + let l:list = substitute(l:list, "\x02", l:buftabs_marker_end, 'g') + + " Show the list. The buftabs_in_statusline variable determines of the list + " is displayed in the command line (volatile) or in the statusline + " (persistent) + + if exists("g:buftabs_in_statusline") + let &l:statusline = l:list . w:original_statusline + else + redraw + call Pecho(l:list) + end + +endfunction + + +" Hook to events to show buftabs at startup, when creating and when switching +" buffers + +autocmd VimEnter * call Buftabs_enable() +autocmd VimEnter,BufNew,BufEnter,BufWritePost * call Buftabs_show(-1) +autocmd BufDelete * call Buftabs_show(expand('<abuf>')) +if version >= 700 + autocmd InsertLeave,VimResized * call Buftabs_show(-1) +end + +" vi: ts=2 sw=2 + diff --git a/.vim/plugin/c.vim b/.vim/plugin/c.vim new file mode 100644 index 0000000..741764b --- /dev/null +++ b/.vim/plugin/c.vim @@ -0,0 +1,3550 @@ +"################################################################################# +" +" Filename: c.vim +" +" Description: C/C++-IDE. Write programs by inserting complete statements, +" comments, idioms, code snippets, templates and comments. +" Compile, link and run one-file-programs without a makefile. +" See also help file csupport.txt . +" +" GVIM Version: 7.0+ +" +" Configuration: There are some personal details which should be configured +" (see the files README.csupport and csupport.txt). +" +" Author: Dr.-Ing. Fritz Mehner, FH Südwestfalen, 58644 Iserlohn, Germany +" Email: mehner@fh-swf.de +" +" Version: see variable g:C_Version below +" Created: 04.11.2000 +" License: Copyright (c) 2000-2010, Fritz Mehner +" This program is free software; you can redistribute it and/or +" modify it under the terms of the GNU General Public License as +" published by the Free Software Foundation, version 2 of the +" License. +" This program is distributed in the hope that it will be +" useful, but WITHOUT ANY WARRANTY; without even the implied +" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +" PURPOSE. +" See the GNU General Public License version 2 for more details. +" Revision: $Id: c.vim,v 1.106 2010/02/02 13:24:41 mehner Exp $ +" +"------------------------------------------------------------------------------ +" +if v:version < 700 + echohl WarningMsg | echo 'The plugin c-support.vim needs Vim version >= 7 .'| echohl None + finish +endif +" +" Prevent duplicate loading: +" +if exists("g:C_Version") || &cp + finish +endif +let g:C_Version= "5.10" " version number of this script; do not change +" +"################################################################################# +" +" Global variables (with default values) which can be overridden. +" +" Platform specific items: {{{1 +" - root directory +" - characters that must be escaped for filenames +" +let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") +" +if s:MSWIN + " + let s:escfilename = '' + let s:plugin_dir = $VIM.'\vimfiles\' + let s:C_CodeSnippets = s:plugin_dir.'c-support/codesnippets/' + let s:C_IndentErrorLog = $HOME.'.indent.errorlog' + let s:installation = 'system' + " + let s:C_Display = '' + " +else + " + let s:escfilename = ' \%#[]' + let s:installation = 'local' + " + " user / system wide installation (Linux/Unix) + " + if match( expand("<sfile>"), $VIM ) >= 0 + " system wide installation + let s:plugin_dir = $VIM.'/vimfiles/' + let s:installation = 'system' + else + " user installation assumed + let s:plugin_dir = $HOME.'/.vim/' + endif + " + let s:C_CodeSnippets = $HOME.'/.vim/c-support/codesnippets/' + let s:C_IndentErrorLog = $HOME.'/.indent.errorlog' + " + let s:C_Display = system("echo -n $DISPLAY") + " +endif +" Use of dictionaries {{{1 +" Key word completion is enabled by the filetype plugin 'c.vim' +" g:C_Dictionary_File must be global +" +if !exists("g:C_Dictionary_File") + let g:C_Dictionary_File = s:plugin_dir.'c-support/wordlists/c-c++-keywords.list,'. + \ s:plugin_dir.'c-support/wordlists/k+r.list,'. + \ s:plugin_dir.'c-support/wordlists/stl_index.list' +endif +" +" Modul global variables (with default values) which can be overridden. {{{1 +" +if s:MSWIN + let s:C_CCompiler = 'gcc.exe' " the C compiler + let s:C_CplusCompiler = 'g++.exe' " the C++ compiler + let s:C_ExeExtension = '.exe' " file extension for executables (leading point required) + let s:C_ObjExtension = '.obj' " file extension for objects (leading point required) + let s:C_Man = 'man.exe' " the manual program +else + let s:C_CCompiler = 'gcc' " the C compiler + let s:C_CplusCompiler = 'g++' " the C++ compiler + let s:C_ExeExtension = '' " file extension for executables (leading point required) + let s:C_ObjExtension = '.o' " file extension for objects (leading point required) + let s:C_Man = 'man' " the manual program +endif +" +let s:C_CExtension = 'c' " C file extension; everything else is C++ +let s:C_CFlags = '-Wall -g -O0 -c' " compiler flags: compile, don't optimize +let s:C_CodeCheckExeName = 'check' +let s:C_CodeCheckOptions = '-K13' +let s:C_LFlags = '-Wall -g -O0' " compiler flags: link , don't optimize +let s:C_Libs = '-lm' " libraries to use +let s:C_LineEndCommColDefault = 49 +let s:C_LoadMenus = 'yes' +let s:C_MenuHeader = 'yes' +let s:C_OutputGvim = 'vim' +let s:C_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" +let s:C_Root = '&C\/C\+\+.' " the name of the root menu of this plugin +let s:C_TypeOfH = 'cpp' +let s:C_Wrapper = s:plugin_dir.'c-support/scripts/wrapper.sh' +let s:C_XtermDefaults = '-fa courier -fs 12 -geometry 80x24' +let s:C_GuiSnippetBrowser = 'gui' " gui / commandline +let s:C_GuiTemplateBrowser = 'gui' " gui / explorer / commandline +" +let s:C_GlobalTemplateFile = s:plugin_dir.'c-support/templates/Templates' +let s:C_GlobalTemplateDir = fnamemodify( s:C_GlobalTemplateFile, ":p:h" ).'/' +let s:C_LocalTemplateFile = $HOME.'/.vim/c-support/templates/Templates' +let s:C_LocalTemplateDir = fnamemodify( s:C_LocalTemplateFile, ":p:h" ).'/' +let s:C_TemplateOverwrittenMsg= 'yes' +let s:C_Ctrl_j = 'on' +" +let s:C_FormatDate = '%x' +let s:C_FormatTime = '%X' +let s:C_FormatYear = '%Y' +let s:C_SourceCodeExtensions = 'c cc cp cxx cpp CPP c++ C i ii' +" +"------------------------------------------------------------------------------ +" +" Look for global variables (if any), to override the defaults. +" +function! C_CheckGlobal ( name ) + if exists('g:'.a:name) + exe 'let s:'.a:name.' = g:'.a:name + endif +endfunction " ---------- end of function C_CheckGlobal ---------- +" +call C_CheckGlobal('C_CCompiler ') +call C_CheckGlobal('C_CExtension ') +call C_CheckGlobal('C_CFlags ') +call C_CheckGlobal('C_CodeCheckExeName ') +call C_CheckGlobal('C_CodeCheckOptions ') +call C_CheckGlobal('C_CodeSnippets ') +call C_CheckGlobal('C_CplusCompiler ') +call C_CheckGlobal('C_Ctrl_j ') +call C_CheckGlobal('C_ExeExtension ') +call C_CheckGlobal('C_FormatDate ') +call C_CheckGlobal('C_FormatTime ') +call C_CheckGlobal('C_FormatYear ') +call C_CheckGlobal('C_GlobalTemplateFile ') +call C_CheckGlobal('C_GuiSnippetBrowser ') +call C_CheckGlobal('C_GuiTemplateBrowser ') +call C_CheckGlobal('C_IndentErrorLog ') +call C_CheckGlobal('C_LFlags ') +call C_CheckGlobal('C_Libs ') +call C_CheckGlobal('C_LineEndCommColDefault ') +call C_CheckGlobal('C_LoadMenus ') +call C_CheckGlobal('C_LocalTemplateFile ') +call C_CheckGlobal('C_Man ') +call C_CheckGlobal('C_MenuHeader ') +call C_CheckGlobal('C_ObjExtension ') +call C_CheckGlobal('C_OutputGvim ') +call C_CheckGlobal('C_Printheader ') +call C_CheckGlobal('C_Root ') +call C_CheckGlobal('C_SourceCodeExtensions ') +call C_CheckGlobal('C_TemplateOverwrittenMsg ') +call C_CheckGlobal('C_TypeOfH ') +call C_CheckGlobal('C_XtermDefaults ') +" +"----- some variables for internal use only ----------------------------------- +" +" +" set default geometry if not specified +" +if match( s:C_XtermDefaults, "-geometry\\s\\+\\d\\+x\\d\\+" ) < 0 + let s:C_XtermDefaults = s:C_XtermDefaults." -geometry 80x24" +endif +" +" escape the printheader +" +let s:C_Printheader = escape( s:C_Printheader, ' %' ) +" +let s:C_HlMessage = "" +" +" characters that must be escaped for filenames +" +let s:C_If0_Counter = 0 +let s:C_If0_Txt = "If0Label_" +" +let s:C_SplintIsExecutable = 0 +if executable( "splint" ) + let s:C_SplintIsExecutable = 1 +endif +" +let s:C_CodeCheckIsExecutable = 0 +if executable( s:C_CodeCheckExeName ) + let s:C_CodeCheckIsExecutable = 1 +endif +" +"------------------------------------------------------------------------------ +" Control variables (not user configurable) +"------------------------------------------------------------------------------ +let s:Attribute = { 'below':'', 'above':'', 'start':'', 'append':'', 'insert':'' } +let s:C_Attribute = {} +let s:C_ExpansionLimit = 10 +let s:C_FileVisited = [] +" +let s:C_MacroNameRegex = '\([a-zA-Z][a-zA-Z0-9_]*\)' +let s:C_MacroLineRegex = '^\s*|'.s:C_MacroNameRegex.'|\s*=\s*\(.*\)' +let s:C_MacroCommentRegex = '^\$' +let s:C_ExpansionRegex = '|?'.s:C_MacroNameRegex.'\(:\a\)\?|' +let s:C_NonExpansionRegex = '|'.s:C_MacroNameRegex.'\(:\a\)\?|' +" +let s:C_TemplateNameDelimiter = '-+_,\. ' +let s:C_TemplateLineRegex = '^==\s*\([a-zA-Z][0-9a-zA-Z'.s:C_TemplateNameDelimiter +let s:C_TemplateLineRegex .= ']\+\)\s*==\s*\([a-z]\+\s*==\)\?' +let s:C_TemplateIf = '^==\s*IF\s\+|STYLE|\s\+IS\s\+'.s:C_MacroNameRegex.'\s*==' +let s:C_TemplateEndif = '^==\s*ENDIF\s*==' +" +let s:C_ExpansionCounter = {} +let s:C_TJT = '[ 0-9a-zA-Z_]*' +let s:C_TemplateJumpTarget1 = '<+'.s:C_TJT.'+>\|{+'.s:C_TJT.'+}' +let s:C_TemplateJumpTarget2 = '<-'.s:C_TJT.'->\|{-'.s:C_TJT.'-}' +let s:C_Macro = {'|AUTHOR|' : 'first name surname', + \ '|AUTHORREF|' : '', + \ '|EMAIL|' : '', + \ '|COMPANY|' : '', + \ '|PROJECT|' : '', + \ '|COPYRIGHTHOLDER|': '', + \ '|STYLE|' : '' + \ } +let s:C_MacroFlag = { ':l' : 'lowercase' , + \ ':u' : 'uppercase' , + \ ':c' : 'capitalize' , + \ ':L' : 'legalize name' , + \ } +let s:C_ActualStyle = 'default' +let s:C_ActualStyleLast = s:C_ActualStyle +let s:C_Template = { 'default' : {} } + +let s:C_ForTypes = [ + \ 'char ' , + \ 'int ' , + \ 'long int ' , + \ 'long ' , + \ 'short int ' , + \ 'short ' , + \ 'size_t ' , + \ 'unsigned char ' , + \ 'unsigned int ' , + \ 'unsigned long int ' , + \ 'unsigned long ' , + \ 'unsigned short int ', + \ 'unsigned short ' , + \ 'unsigned ' , + \ ] + +let s:MsgInsNotAvail = "insertion not available for a fold" + +"------------------------------------------------------------------------------ + +let s:C_SourceCodeExtensionsList = split( s:C_SourceCodeExtensions, '\s\+' ) + +"------------------------------------------------------------------------------ + +"------------------------------------------------------------------------------ +" C : C_InitMenus {{{1 +" Initialization of C support menus +"------------------------------------------------------------------------------ +" +" the menu names +" +let s:Comments = s:C_Root.'&Comments' +let s:Statements = s:C_Root.'&Statements' +let s:Idioms = s:C_Root.'&Idioms' +let s:Preprocessor = s:C_Root.'&Preprocessor' +let s:Snippets = s:C_Root.'S&nippets' +let s:Cpp = s:C_Root.'C&++' +let s:Run = s:C_Root.'&Run' +" +function! C_InitMenus () + " + "=============================================================================================== + "----- Menu : C main menu entry ------------------------------------------- {{{2 + "=============================================================================================== + " + if s:C_Root != "" + if s:C_MenuHeader == 'yes' + exe "amenu ".s:C_Root.'C\/C\+\+ <Nop>' + exe "amenu ".s:C_Root.'-Sep00- <Nop>' + endif + endif + " + "=============================================================================================== + "----- Menu : C-Comments -------------------------------------------------- {{{2 + "=============================================================================================== + " + if s:C_MenuHeader == 'yes' + exe "amenu ".s:C_Root.'&Comments.&Comments<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:C_Root.'&Comments.-Sep00- <Nop>' + endif + exe "amenu <silent> ".s:Comments.'.end-of-&line\ comment<Tab>\\cl :call C_LineEndComment( )<CR>' + exe "vmenu <silent> ".s:Comments.'.end-of-&line\ comment<Tab>\\cl <Esc>:call C_MultiLineEndComments( )<CR>a' + + exe "amenu <silent> ".s:Comments.'.ad&just\ end-of-line\ com\.<Tab>\\cj :call C_AdjustLineEndComm("a")<CR>' + exe "vmenu <silent> ".s:Comments.'.ad&just\ end-of-line\ com\.<Tab>\\cj :call C_AdjustLineEndComm("v")<CR>' + + exe "amenu <silent> ".s:Comments.'.&set\ end-of-line\ com\.\ col\.<Tab>\\cs :call C_GetLineEndCommCol()<CR>' + + exe "amenu ".s:Comments.'.-SEP10- :' + exe "amenu <silent> ".s:Comments.'.code\ ->\ comment\ \/&*\ *\/<Tab>\\c* :call C_CodeComment("a","yes")<CR>:nohlsearch<CR>j' + exe "vmenu <silent> ".s:Comments.'.code\ ->\ comment\ \/&*\ *\/<Tab>\\c* <Esc>:call C_CodeComment("v","yes")<CR>:nohlsearch<CR>j' + exe "amenu <silent> ".s:Comments.'.code\ ->\ comment\ &\/\/<Tab>\\cc :call C_CodeComment("a","no")<CR>:nohlsearch<CR>j' + exe "vmenu <silent> ".s:Comments.'.code\ ->\ comment\ &\/\/<Tab>\\cc <Esc>:call C_CodeComment("v","no")<CR>:nohlsearch<CR>j' + exe "amenu <silent> ".s:Comments.'.c&omment\ ->\ code<Tab>\\co :call C_CommentCode("a")<CR>:nohlsearch<CR>' + exe "vmenu <silent> ".s:Comments.'.c&omment\ ->\ code<Tab>\\co :call C_CommentCode("v")<CR>:nohlsearch<CR>' + + exe "amenu ".s:Comments.'.-SEP0- :' + exe "amenu <silent> ".s:Comments.'.&frame\ comment<Tab>\\cfr :call C_InsertTemplate("comment.frame")<CR>' + exe "amenu <silent> ".s:Comments.'.f&unction\ description<Tab>\\cfu :call C_InsertTemplate("comment.function")<CR>' + exe "amenu ".s:Comments.'.-SEP1- :' + exe "amenu <silent> ".s:Comments.'.&method\ description<Tab>\\cme :call C_InsertTemplate("comment.method")<CR>' + exe "amenu <silent> ".s:Comments.'.cl&ass\ description<Tab>\\ccl :call C_InsertTemplate("comment.class")<CR>' + exe "amenu ".s:Comments.'.-SEP2- :' + exe "amenu <silent> ".s:Comments.'.file\ description\ \(impl\.\)<Tab>\\cfdi :call C_InsertTemplate("comment.file-description")<CR>' + exe "amenu <silent> ".s:Comments.'.file\ description\ \(header\)<Tab>\\cfdh :call C_InsertTemplate("comment.file-description-header")<CR>' + exe "amenu ".s:Comments.'.-SEP3- :' + " + "----- Submenu : C-Comments : file sections ------------------------------------------------------------- + " + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.file\ sections<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.-Sep0- <Nop>' + " + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.&Header\ File\ Includes :call C_InsertTemplate("comment.file-section-cpp-header-includes")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.Local\ &Macros :call C_InsertTemplate("comment.file-section-cpp-macros")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.Local\ &Type\ Def\. :call C_InsertTemplate("comment.file-section-cpp-typedefs")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.Local\ &Data\ Types :call C_InsertTemplate("comment.file-section-cpp-data-types")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.Local\ &Variables :call C_InsertTemplate("comment.file-section-cpp-local-variables")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.Local\ &Prototypes :call C_InsertTemplate("comment.file-section-cpp-prototypes")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.&Exp\.\ Function\ Def\. :call C_InsertTemplate("comment.file-section-cpp-function-defs-exported")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.&Local\ Function\ Def\. :call C_InsertTemplate("comment.file-section-cpp-function-defs-local")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.-SEP6- :' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.Local\ &Class\ Def\. :call C_InsertTemplate("comment.file-section-cpp-class-defs")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.E&xp\.\ Class\ Impl\. :call C_InsertTemplate("comment.file-section-cpp-class-implementations-exported")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.L&ocal\ Class\ Impl\. :call C_InsertTemplate("comment.file-section-cpp-class-implementations-local")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.-SEP7- :' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.&All\ sections,\ C :call C_Comment_C_SectionAll("c")<CR>' + exe "amenu ".s:Comments.'.&C\/C\+\+-file\ sections<Tab>\\ccs.All\ §ions,\ C++ :call C_Comment_C_SectionAll("cpp")<CR>' + " + "----- Submenu : H-Comments : file sections ------------------------------------------------------------- + " + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.H-file\ sections<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.-Sep0- <Nop>' + "' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.&Header\ File\ Includes :call C_InsertTemplate("comment.file-section-hpp-header-includes")<CR>' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.Exported\ &Macros :call C_InsertTemplate("comment.file-section-hpp-macros")<CR>' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.Exported\ &Type\ Def\. :call C_InsertTemplate("comment.file-section-hpp-exported-typedefs")<CR>' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.Exported\ &Data\ Types :call C_InsertTemplate("comment.file-section-hpp-exported-data-types")<CR>' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.Exported\ &Variables :call C_InsertTemplate("comment.file-section-hpp-exported-variables")<CR>' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.Exported\ &Funct\.\ Decl\. :call C_InsertTemplate("comment.file-section-hpp-exported-function-declarations")<CR>' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.-SEP4- :' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.E&xported\ Class\ Def\. :call C_InsertTemplate("comment.file-section-hpp-exported-class-defs")<CR>' + + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.-SEP5- :' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.&All\ sections,\ C :call C_Comment_H_SectionAll("c")<CR>' + exe "amenu ".s:Comments.'.&H-file\ sections<Tab>\\chs.All\ §ions,\ C++ :call C_Comment_H_SectionAll("cpp")<CR>' + " + exe "amenu ".s:Comments.'.-SEP8- :' + " + "----- Submenu : C-Comments : keyword comments ---------------------------------------------------------- + " + exe "amenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.keyw\.+comm\.<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.-Sep0- <Nop>' +" + exe "amenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:&BUG\: $:call C_InsertTemplate("comment.keyword-bug")<CR>' + exe "amenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:&COMPILER\: $:call C_InsertTemplate("comment.keyword-compiler")<CR>' + exe "amenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:&TODO\: $:call C_InsertTemplate("comment.keyword-todo")<CR>' + exe "amenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:T&RICKY\: $:call C_InsertTemplate("comment.keyword-tricky")<CR>' + exe "amenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:&WARNING\: $:call C_InsertTemplate("comment.keyword-warning")<CR>' + exe "amenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:W&ORKAROUND\: $:call C_InsertTemplate("comment.keyword-workaround")<CR>' + exe "amenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:&new\ keyword\: $:call C_InsertTemplate("comment.keyword-keyword")<CR>' +" + exe "imenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:&BUG\: <Esc>$:call C_InsertTemplate("comment.keyword-bug")<CR>' + exe "imenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:&COMPILER\: <Esc>$:call C_InsertTemplate("comment.keyword-compiler")<CR>' + exe "imenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:&TODO\: <Esc>$:call C_InsertTemplate("comment.keyword-todo")<CR>' + exe "imenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:T&RICKY\: <Esc>$:call C_InsertTemplate("comment.keyword-tricky")<CR>' + exe "imenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:&WARNING\: <Esc>$:call C_InsertTemplate("comment.keyword-warning")<CR>' + exe "imenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:W&ORKAROUND\: <Esc>$:call C_InsertTemplate("comment.keyword-workaround")<CR>' + exe "imenu ".s:Comments.'.&keyword\ comm\.<Tab>\\ckc.\:&new\ keyword\: <Esc>$:call C_InsertTemplate("comment.keyword-keyword")<CR>' + " + "----- Submenu : C-Comments : special comments ---------------------------------------------------------- + " + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.special\ comm\.<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.-Sep0- <Nop>' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.&EMPTY $:call C_InsertTemplate("comment.special-empty")<CR>' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.&FALL\ THROUGH $:call C_InsertTemplate("comment.special-fall-through") <CR>' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.&IMPL\.\ TYPE\ CONV $:call C_InsertTemplate("comment.special-implicit-type-conversion") <CR>' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.&NO\ RETURN $:call C_InsertTemplate("comment.special-no-return") <CR>' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.NOT\ &REACHED $:call C_InsertTemplate("comment.special-not-reached") <CR>' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.&TO\ BE\ IMPL\. $:call C_InsertTemplate("comment.special-remains-to-be-implemented")<CR>' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.-SEP81- :' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.constant\ type\ is\ &long\ (L) $:call C_InsertTemplate("comment.special-constant-type-is-long")<CR>' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.constant\ type\ is\ &unsigned\ (U) $:call C_InsertTemplate("comment.special-constant-type-is-unsigned")<CR>' + exe "amenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.constant\ type\ is\ unsigned\ l&ong\ (UL) $:call C_InsertTemplate("comment.special-constant-type-is-unsigned-long")<CR>' + " + exe "imenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.&EMPTY <Esc>$:call C_InsertTemplate("comment.special-empty")<CR>' + exe "imenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.&FALL\ THROUGH <Esc>$:call C_InsertTemplate("comment.special-fall-through") <CR>' + exe "imenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.&IMPL\.\ TYPE\ CONV <Esc>$:call C_InsertTemplate("comment.special-implicit-type-conversion") <CR>' + exe "imenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.&NO\ RETURN <Esc>$:call C_InsertTemplate("comment.special-no-return") <CR>' + exe "imenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.NOT\ &REACHED <Esc>$:call C_InsertTemplate("comment.special-not-reached") <CR>' + exe "imenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.&TO\ BE\ IMPL\. <Esc>$:call C_InsertTemplate("comment.special-remains-to-be-implemented")<CR>' + exe "imenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.-SEP81- :' + exe "imenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.constant\ type\ is\ &long\ (L) <Esc>$:call C_InsertTemplate("comment.special-constant-type-is-long")<CR>' + exe "imenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.constant\ type\ is\ &unsigned\ (U) <Esc>$:call C_InsertTemplate("comment.special-constant-type-is-unsigned")<CR>' + exe "imenu ".s:Comments.'.&special\ comm\.<Tab>\\ckc.constant\ type\ is\ unsigned\ l&ong\ (UL) <Esc>$:call C_InsertTemplate("comment.special-constant-type-is-unsigned-long")<CR>' + " + "----- Submenu : C-Comments : Tags ---------------------------------------------------------- + " + exe "amenu ".s:Comments.'.ta&gs\ (plugin).tags\ (plugin)<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Comments.'.ta&gs\ (plugin).-Sep0- <Nop>' + " + exe "anoremenu ".s:Comments.'.ta&gs\ (plugin).&AUTHOR :call C_InsertMacroValue("AUTHOR")<CR>' + exe "anoremenu ".s:Comments.'.ta&gs\ (plugin).AUTHOR&REF :call C_InsertMacroValue("AUTHORREF")<CR>' + exe "anoremenu ".s:Comments.'.ta&gs\ (plugin).&COMPANY :call C_InsertMacroValue("COMPANY")<CR>' + exe "anoremenu ".s:Comments.'.ta&gs\ (plugin).C&OPYRIGHTHOLDER :call C_InsertMacroValue("COPYRIGHTHOLDER")<CR>' + exe "anoremenu ".s:Comments.'.ta&gs\ (plugin).&EMAIL :call C_InsertMacroValue("EMAIL")<CR>' + exe "anoremenu ".s:Comments.'.ta&gs\ (plugin).&PROJECT :call C_InsertMacroValue("PROJECT")<CR>' + " + exe "inoremenu ".s:Comments.'.ta&gs\ (plugin).&AUTHOR <Esc>:call C_InsertMacroValue("AUTHOR")<CR>a' + exe "inoremenu ".s:Comments.'.ta&gs\ (plugin).AUTHOR&REF <Esc>:call C_InsertMacroValue("AUTHORREF")<CR>a' + exe "inoremenu ".s:Comments.'.ta&gs\ (plugin).&COMPANY <Esc>:call C_InsertMacroValue("COMPANY")<CR>a' + exe "inoremenu ".s:Comments.'.ta&gs\ (plugin).C&OPYRIGHTHOLDER <Esc>:call C_InsertMacroValue("COPYRIGHTHOLDER")<CR>a' + exe "inoremenu ".s:Comments.'.ta&gs\ (plugin).&EMAIL <Esc>:call C_InsertMacroValue("EMAIL")<CR>a' + exe "inoremenu ".s:Comments.'.ta&gs\ (plugin).&PROJECT <Esc>:call C_InsertMacroValue("PROJECT")<CR>a' + " + exe "vnoremenu ".s:Comments.'.ta&gs\ (plugin).&AUTHOR s<Esc>:call C_InsertMacroValue("AUTHOR")<CR>a' + exe "vnoremenu ".s:Comments.'.ta&gs\ (plugin).AUTHOR&REF s<Esc>:call C_InsertMacroValue("AUTHORREF")<CR>a' + exe "vnoremenu ".s:Comments.'.ta&gs\ (plugin).&COMPANY s<Esc>:call C_InsertMacroValue("COMPANY")<CR>a' + exe "vnoremenu ".s:Comments.'.ta&gs\ (plugin).C&OPYRIGHTHOLDER s<Esc>:call C_InsertMacroValue("COPYRIGHTHOLDER")<CR>a' + exe "vnoremenu ".s:Comments.'.ta&gs\ (plugin).&EMAIL s<Esc>:call C_InsertMacroValue("EMAIL")<CR>a' + exe "vnoremenu ".s:Comments.'.ta&gs\ (plugin).&PROJECT s<Esc>:call C_InsertMacroValue("PROJECT")<CR>a' + " + " + exe "amenu ".s:Comments.'.-SEP9- :' + " + exe " menu ".s:Comments.'.&date<Tab>\\cd <Esc>:call C_InsertDateAndTime("d")<CR>' + exe "imenu ".s:Comments.'.&date<Tab>\\cd <Esc>:call C_InsertDateAndTime("d")<CR>a' + exe "vmenu ".s:Comments.'.&date<Tab>\\cd s<Esc>:call C_InsertDateAndTime("d")<CR>a' + exe " menu ".s:Comments.'.date\ &time<Tab>\\ct <Esc>:call C_InsertDateAndTime("dt")<CR>' + exe "imenu ".s:Comments.'.date\ &time<Tab>\\ct <Esc>:call C_InsertDateAndTime("dt")<CR>a' + exe "vmenu ".s:Comments.'.date\ &time<Tab>\\ct s<Esc>:call C_InsertDateAndTime("dt")<CR>a' + + exe "amenu ".s:Comments.'.-SEP12- :' + exe "amenu <silent> ".s:Comments.'.\/\/\ xxx\ \ \ \ \ &->\ \ \/*\ xxx\ *\/ :call C_CommentCppToC()<CR>' + exe "vmenu <silent> ".s:Comments.'.\/\/\ xxx\ \ \ \ \ &->\ \ \/*\ xxx\ *\/ <Esc>:'."'<,'>".'call C_CommentCppToC()<CR>' + exe "amenu <silent> ".s:Comments.'.\/*\ xxx\ *\/\ \ -&>\ \ \/\/\ xxx :call C_CommentCToCpp()<CR>' + exe "vmenu <silent> ".s:Comments.'.\/*\ xxx\ *\/\ \ -&>\ \ \/\/\ xxx <Esc>:'."'<,'>".'call C_CommentCToCpp()<CR>' + " + "=============================================================================================== + "----- Menu : C-Statements------------------------------------------------- {{{2 + "=============================================================================================== + " + if s:C_MenuHeader == 'yes' + exe "amenu ".s:Statements.'.&Statements<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Statements.'.-Sep00- <Nop>' + endif + " + exe "amenu <silent>".s:Statements.'.&do\ \{\ \}\ while<Tab>\\sd :call C_InsertTemplate("statements.do-while")<CR>' + exe "vmenu <silent>".s:Statements.'.&do\ \{\ \}\ while<Tab>\\sd <Esc>:call C_InsertTemplate("statements.do-while", "v")<CR>' + exe "imenu <silent>".s:Statements.'.&do\ \{\ \}\ while<Tab>\\sd <Esc>:call C_InsertTemplate("statements.do-while")<CR>' + " + exe "amenu <silent>".s:Statements.'.f&or<Tab>\\sf :call C_InsertTemplate("statements.for")<CR>' + exe "imenu <silent>".s:Statements.'.f&or<Tab>\\sf <Esc>:call C_InsertTemplate("statements.for")<CR>' + " + exe "amenu <silent>".s:Statements.'.fo&r\ \{\ \}<Tab>\\sfo :call C_InsertTemplate("statements.for-block")<CR>' + exe "vmenu <silent>".s:Statements.'.fo&r\ \{\ \}<Tab>\\sfo <Esc>:call C_InsertTemplate("statements.for-block", "v")<CR>' + exe "imenu <silent>".s:Statements.'.fo&r\ \{\ \}<Tab>\\sfo <Esc>:call C_InsertTemplate("statements.for-block")<CR>' + " + exe "amenu <silent>".s:Statements.'.&if<Tab>\\si :call C_InsertTemplate("statements.if")<CR>' + exe "imenu <silent>".s:Statements.'.&if<Tab>\\si <Esc>:call C_InsertTemplate("statements.if")<CR>' + " + exe "amenu <silent>".s:Statements.'.i&f\ \{\ \}<Tab>\\sif :call C_InsertTemplate("statements.if-block")<CR>' + exe "vmenu <silent>".s:Statements.'.i&f\ \{\ \}<Tab>\\sif <Esc>:call C_InsertTemplate("statements.if-block", "v")<CR>' + exe "imenu <silent>".s:Statements.'.i&f\ \{\ \}<Tab>\\sif <Esc>:call C_InsertTemplate("statements.if-block")<CR>' + + exe "amenu <silent>".s:Statements.'.if\ &else<Tab>\\sie :call C_InsertTemplate("statements.if-else")<CR>' + exe "vmenu <silent>".s:Statements.'.if\ &else<Tab>\\sie <Esc>:call C_InsertTemplate("statements.if-else", "v")<CR>' + exe "imenu <silent>".s:Statements.'.if\ &else<Tab>\\sie <Esc>:call C_InsertTemplate("statements.if-else")<CR>' + " + exe "amenu <silent>".s:Statements.'.if\ \{\ \}\ e&lse\ \{\ \}<Tab>\\sife :call C_InsertTemplate("statements.if-block-else")<CR>' + exe "vmenu <silent>".s:Statements.'.if\ \{\ \}\ e&lse\ \{\ \}<Tab>\\sife <Esc>:call C_InsertTemplate("statements.if-block-else", "v")<CR>' + exe "imenu <silent>".s:Statements.'.if\ \{\ \}\ e&lse\ \{\ \}<Tab>\\sife <Esc>:call C_InsertTemplate("statements.if-block-else")<CR>' + " + exe "amenu <silent>".s:Statements.'.&else\ \{\ \}<Tab>\\se :call C_InsertTemplate("statements.else-block")<CR>' + exe "vmenu <silent>".s:Statements.'.&else\ \{\ \}<Tab>\\se <Esc>:call C_InsertTemplate("statements.else-block", "v")<CR>' + exe "imenu <silent>".s:Statements.'.&else\ \{\ \}<Tab>\\se <Esc>:call C_InsertTemplate("statements.else-block")<CR>' + " + exe "amenu <silent>".s:Statements.'.&while<Tab>\\sw :call C_InsertTemplate("statements.while")<CR>' + exe "imenu <silent>".s:Statements.'.&while<Tab>\\sw <Esc>:call C_InsertTemplate("statements.while")<CR>' + " + exe "amenu <silent>".s:Statements.'.w&hile\ \{\ \}<Tab>\\swh :call C_InsertTemplate("statements.while-block")<CR>' + exe "vmenu <silent>".s:Statements.'.w&hile\ \{\ \}<Tab>\\swh <Esc>:call C_InsertTemplate("statements.while-block", "v")<CR>' + exe "imenu <silent>".s:Statements.'.w&hile\ \{\ \}<Tab>\\swh <Esc>:call C_InsertTemplate("statements.while-block")<CR>' + " + exe "amenu <silent>".s:Statements.'.&switch\ \{\ \}<Tab>\\ss :call C_InsertTemplate("statements.switch")<CR>' + exe "vmenu <silent>".s:Statements.'.&switch\ \{\ \}<Tab>\\ss <Esc>:call C_InsertTemplate("statements.switch", "v")<CR>' + exe "imenu <silent>".s:Statements.'.&switch\ \{\ \}<Tab>\\ss <Esc>:call C_InsertTemplate("statements.switch")<CR>' + " + exe "amenu ".s:Statements.'.&case\ \.\.\.\ break<Tab>\\sc :call C_InsertTemplate("statements.case")<CR>' + exe "imenu ".s:Statements.'.&case\ \.\.\.\ break<Tab>\\sc <Esc>:call C_InsertTemplate("statements.case")<CR>' + " + " + exe "amenu <silent>".s:Statements.'.&\{\ \}<Tab>\\sb :call C_InsertTemplate("statements.block")<CR>' + exe "vmenu <silent>".s:Statements.'.&\{\ \}<Tab>\\sb <Esc>:call C_InsertTemplate("statements.block", "v")<CR>' + exe "imenu <silent>".s:Statements.'.&\{\ \}<Tab>\\sb <Esc>:call C_InsertTemplate("statements.block")<CR>' + " + " + "=============================================================================================== + "----- Menu : C-Idioms ---------------------------------------------------- {{{2 + "=============================================================================================== + " + if s:C_MenuHeader == 'yes' + exe "amenu ".s:Idioms.'.&Idioms<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Idioms.'.-Sep00- <Nop>' + endif + exe "amenu <silent> ".s:Idioms.'.&function<Tab>\\if :call C_InsertTemplate("idioms.function")<CR>' + exe "vmenu <silent> ".s:Idioms.'.&function<Tab>\\if <Esc>:call C_InsertTemplate("idioms.function", "v")<CR>' + exe "imenu <silent> ".s:Idioms.'.&function<Tab>\\if <Esc>:call C_InsertTemplate("idioms.function")<CR>' + exe "amenu <silent> ".s:Idioms.'.s&tatic\ function<Tab>\\isf :call C_InsertTemplate("idioms.function-static")<CR>' + exe "vmenu <silent> ".s:Idioms.'.s&tatic\ function<Tab>\\isf <Esc>:call C_InsertTemplate("idioms.function-static", "v")<CR>' + exe "imenu <silent> ".s:Idioms.'.s&tatic\ function<Tab>\\isf <Esc>:call C_InsertTemplate("idioms.function-static")<CR>' + exe "amenu <silent> ".s:Idioms.'.&main<Tab>\\im :call C_InsertTemplate("idioms.main")<CR>' + exe "vmenu <silent> ".s:Idioms.'.&main<Tab>\\im <Esc>:call C_InsertTemplate("idioms.main", "v")<CR>' + exe "imenu <silent> ".s:Idioms.'.&main<Tab>\\im <Esc>:call C_InsertTemplate("idioms.main")<CR>' + + exe "amenu ".s:Idioms.'.-SEP1- :' + exe "amenu ".s:Idioms.'.for(x=&0;\ x<n;\ x\+=1)<Tab>\\i0 :call C_CodeFor("up" , "a")<CR>' + exe "vmenu ".s:Idioms.'.for(x=&0;\ x<n;\ x\+=1)<Tab>\\i0 <Esc>:call C_CodeFor("up" , "v")<CR>' + exe "imenu ".s:Idioms.'.for(x=&0;\ x<n;\ x\+=1)<Tab>\\i0 <Esc>:call C_CodeFor("up" , "a")<CR>i' + exe "amenu ".s:Idioms.'.for(x=&n-1;\ x>=0;\ x\-=1)<Tab>\\in :call C_CodeFor("down", "a")<CR>' + exe "vmenu ".s:Idioms.'.for(x=&n-1;\ x>=0;\ x\-=1)<Tab>\\in <Esc>:call C_CodeFor("down", "v")<CR>' + exe "imenu ".s:Idioms.'.for(x=&n-1;\ x>=0;\ x\-=1)<Tab>\\in <Esc>:call C_CodeFor("down", "a")<CR>i' + + exe "amenu ".s:Idioms.'.-SEP2- :' + exe "amenu <silent> ".s:Idioms.'.&enum<Tab>\\ie :call C_InsertTemplate("idioms.enum")<CR>' + exe "vmenu <silent> ".s:Idioms.'.&enum<Tab>\\ie <Esc>:call C_InsertTemplate("idioms.enum" , "v")<CR>' + exe "imenu <silent> ".s:Idioms.'.&enum<Tab>\\ie <Esc>:call C_InsertTemplate("idioms.enum" )<CR>' + exe "amenu <silent> ".s:Idioms.'.&struct<Tab>\\is :call C_InsertTemplate("idioms.struct")<CR>' + exe "vmenu <silent> ".s:Idioms.'.&struct<Tab>\\is <Esc>:call C_InsertTemplate("idioms.struct", "v")<CR>' + exe "imenu <silent> ".s:Idioms.'.&struct<Tab>\\is <Esc>:call C_InsertTemplate("idioms.struct")<CR>' + exe "amenu <silent> ".s:Idioms.'.&union<Tab>\\iu :call C_InsertTemplate("idioms.union")<CR>' + exe "vmenu <silent> ".s:Idioms.'.&union<Tab>\\iu <Esc>:call C_InsertTemplate("idioms.union" , "v")<CR>' + exe "imenu <silent> ".s:Idioms.'.&union<Tab>\\iu <Esc>:call C_InsertTemplate("idioms.union" )<CR>' + exe "amenu ".s:Idioms.'.-SEP3- :' + " + exe "amenu <silent> ".s:Idioms.'.scanf<Tab>\\isc :call C_InsertTemplate("idioms.scanf")<CR>' + exe "imenu <silent> ".s:Idioms.'.scanf<Tab>\\isc <Esc>:call C_InsertTemplate("idioms.scanf")<CR>' + exe "amenu <silent> ".s:Idioms.'.printf<Tab>\\ip :call C_InsertTemplate("idioms.printf")<CR>' + exe "imenu <silent> ".s:Idioms.'.printf<Tab>\\ip <Esc>:call C_InsertTemplate("idioms.printf")<CR>' + " + exe "amenu ".s:Idioms.'.-SEP4- :' + exe "amenu <silent> ".s:Idioms.'.p=ca&lloc\(n,sizeof(type)\)<Tab>\\ica :call C_InsertTemplate("idioms.calloc")<CR>' + exe "imenu <silent> ".s:Idioms.'.p=ca&lloc\(n,sizeof(type)\)<Tab>\\ica <Esc>:call C_InsertTemplate("idioms.calloc")<CR>' + exe "amenu <silent> ".s:Idioms.'.p=m&alloc\(sizeof(type)\)<Tab>\\ima :call C_InsertTemplate("idioms.malloc")<CR>' + exe "imenu <silent> ".s:Idioms.'.p=m&alloc\(sizeof(type)\)<Tab>\\ima <Esc>:call C_InsertTemplate("idioms.malloc")<CR>' + " + exe "anoremenu <silent> ".s:Idioms.'.si&zeof(\ \)<Tab>\\isi :call C_InsertTemplate("idioms.sizeof")<CR>' + exe "inoremenu <silent> ".s:Idioms.'.si&zeof(\ \)<Tab>\\isi <Esc>:call C_InsertTemplate("idioms.sizeof")<CR>' + exe "vnoremenu <silent> ".s:Idioms.'.si&zeof(\ \)<Tab>\\isi <Esc>:call C_InsertTemplate("idioms.sizeof", "v")<CR>' + " + exe "anoremenu <silent> ".s:Idioms.'.asse&rt(\ \)<Tab>\\ias :call C_InsertTemplate("idioms.assert")<CR>' + exe "inoremenu <silent> ".s:Idioms.'.asse&rt(\ \)<Tab>\\ias <Esc>:call C_InsertTemplate("idioms.assert")<CR>' + exe "vnoremenu <silent> ".s:Idioms.'.asse&rt(\ \)<Tab>\\ias <Esc>:call C_InsertTemplate("idioms.assert", "v")<CR>' + + exe "amenu ".s:Idioms.'.-SEP5- :' + exe "amenu <silent> ".s:Idioms.'.open\ &input\ file<Tab>\\ii :call C_InsertTemplate("idioms.open-input-file")<CR>' + exe "imenu <silent> ".s:Idioms.'.open\ &input\ file<Tab>\\ii <Esc>:call C_InsertTemplate("idioms.open-input-file")<CR>' + exe "vmenu <silent> ".s:Idioms.'.open\ &input\ file<Tab>\\ii <Esc>:call C_InsertTemplate("idioms.open-input-file", "v")<CR>' + exe "amenu <silent> ".s:Idioms.'.open\ &output\ file<Tab>\\io :call C_InsertTemplate("idioms.open-output-file")<CR>' + exe "imenu <silent> ".s:Idioms.'.open\ &output\ file<Tab>\\io <Esc>:call C_InsertTemplate("idioms.open-output-file")<CR>' + exe "vmenu <silent> ".s:Idioms.'.open\ &output\ file<Tab>\\io <Esc>:call C_InsertTemplate("idioms.open-output-file", "v")<CR>' + " + exe "amenu <silent> ".s:Idioms.'.fscanf :call C_InsertTemplate("idioms.fscanf")<CR>' + exe "imenu <silent> ".s:Idioms.'.fscanf <Esc>:call C_InsertTemplate("idioms.fscanf")<CR>' + exe "amenu <silent> ".s:Idioms.'.fprintf :call C_InsertTemplate("idioms.fprintf")<CR>' + exe "imenu <silent> ".s:Idioms.'.fprintf <Esc>:call C_InsertTemplate("idioms.fprintf")<CR>' + " + "=============================================================================================== + "----- Menu : C-Preprocessor ---------------------------------------------- {{{2 + "=============================================================================================== + " + if s:C_MenuHeader == 'yes' + exe "amenu ".s:Preprocessor.'.&Preprocessor<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Preprocessor.'.-Sep00- <Nop>' + endif + " + "----- Submenu : C-Idioms: standard library ------------------------------------------------------- + "' + exe "amenu ".s:Preprocessor.'.#include\ &Std\.Lib\.<Tab>\\ps.Std\.Lib\.<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Preprocessor.'.#include\ &Std\.Lib\.<Tab>\\ps.-Sep0- <Nop>' + call C_CIncludeMenus ( s:Preprocessor.'.#include\ &Std\.Lib\.<Tab>\\ps', s:C_StandardLibs ) + " + exe "anoremenu ".s:Preprocessor.'.#include\ C&99<Tab>\\pc.C99<Tab>C\/C\+\+ <Nop>' + exe "anoremenu ".s:Preprocessor.'.#include\ C&99<Tab>\\pc.-Sep0- <Nop>' + call C_CIncludeMenus ( s:Preprocessor.'.#include\ C&99<Tab>\\pc', s:C_C99Libs ) + " + exe "amenu ".s:Preprocessor.'.-SEP2- :' + exe "anoremenu ".s:Preprocessor.'.#include\ &\<\.\.\.\><Tab>\\p< :call C_InsertTemplate("preprocessor.include-global")<CR>' + exe "inoremenu ".s:Preprocessor.'.#include\ &\<\.\.\.\><Tab>\\p< <Esc>:call C_InsertTemplate("preprocessor.include-global")<CR>' + exe "anoremenu ".s:Preprocessor.'.#include\ &\"\.\.\.\"<Tab>\\p" :call C_InsertTemplate("preprocessor.include-local")<CR>' + exe "inoremenu ".s:Preprocessor.'.#include\ &\"\.\.\.\"<Tab>\\p" <Esc>:call C_InsertTemplate("preprocessor.include-local")<CR>' + exe "amenu ".s:Preprocessor.'.#&define<Tab>\\pd :call C_InsertTemplate("preprocessor.define")<CR>' + exe "imenu ".s:Preprocessor.'.#&define<Tab>\\pd <Esc>:call C_InsertTemplate("preprocessor.define")<CR>' + exe "amenu ".s:Preprocessor.'.&#undef<Tab>\\pu :call C_InsertTemplate("preprocessor.undefine")<CR>' + exe "imenu ".s:Preprocessor.'.&#undef<Tab>\\pu <Esc>:call C_InsertTemplate("preprocessor.undefine")<CR>' + " + exe "amenu ".s:Preprocessor.'.#&if\ #else\ #endif<Tab>\\pie :call C_InsertTemplate("preprocessor.if-else-endif")<CR>' + exe "imenu ".s:Preprocessor.'.#&if\ #else\ #endif<Tab>\\pie <Esc>:call C_InsertTemplate("preprocessor.if-else-endif")<CR>' + exe "vmenu ".s:Preprocessor.'.#&if\ #else\ #endif<Tab>\\pie <Esc>:call C_InsertTemplate("preprocessor.if-else-endif", "v")<CR>' + exe "amenu ".s:Preprocessor.'.#i&fdef\ #else\ #endif<Tab>\\pid :call C_InsertTemplate("preprocessor.ifdef-else-endif")<CR>' + exe "imenu ".s:Preprocessor.'.#i&fdef\ #else\ #endif<Tab>\\pid <Esc>:call C_InsertTemplate("preprocessor.ifdef-else-endif")<CR>' + exe "vmenu ".s:Preprocessor.'.#i&fdef\ #else\ #endif<Tab>\\pid <Esc>:call C_InsertTemplate("preprocessor.ifdef-else-endif", "v")<CR>' + exe "amenu ".s:Preprocessor.'.#if&ndef\ #else\ #endif<Tab>\\pin :call C_InsertTemplate("preprocessor.ifndef-else-endif")<CR>' + exe "imenu ".s:Preprocessor.'.#if&ndef\ #else\ #endif<Tab>\\pin <Esc>:call C_InsertTemplate("preprocessor.ifndef-else-endif")<CR>' + exe "vmenu ".s:Preprocessor.'.#if&ndef\ #else\ #endif<Tab>\\pin <Esc>:call C_InsertTemplate("preprocessor.ifndef-else-endif", "v")<CR>' + exe "amenu ".s:Preprocessor.'.#ifnd&ef\ #def\ #endif<Tab>\\pind :call C_InsertTemplate("preprocessor.ifndef-def-endif")<CR>' + exe "imenu ".s:Preprocessor.'.#ifnd&ef\ #def\ #endif<Tab>\\pind <Esc>:call C_InsertTemplate("preprocessor.ifndef-def-endif")<CR>' + exe "vmenu ".s:Preprocessor.'.#ifnd&ef\ #def\ #endif<Tab>\\pind <Esc>:call C_InsertTemplate("preprocessor.ifndef-def-endif", "v")<CR>' + + exe "amenu ".s:Preprocessor.'.#if\ &0\ #endif<Tab>\\pi0 :call C_PPIf0("a")<CR>2ji' + exe "imenu ".s:Preprocessor.'.#if\ &0\ #endif<Tab>\\pi0 <Esc>:call C_PPIf0("a")<CR>2ji' + exe "vmenu ".s:Preprocessor.'.#if\ &0\ #endif<Tab>\\pi0 <Esc>:call C_PPIf0("v")<CR>' + " + exe "amenu <silent> ".s:Preprocessor.'.&remove\ #if\ 0\ #endif<Tab>\\pr0 :call C_PPIf0Remove()<CR>' + exe "imenu <silent> ".s:Preprocessor.'.&remove\ #if\ 0\ #endif<Tab>\\pr0 <Esc>:call C_PPIf0Remove()<CR>' + " + exe "amenu ".s:Preprocessor.'.#err&or<Tab>\\pe :call C_InsertTemplate("preprocessor.error")<CR>' + exe "imenu ".s:Preprocessor.'.#err&or<Tab>\\pe <C-C>:call C_InsertTemplate("preprocessor.error")<CR>' + exe "amenu ".s:Preprocessor.'.#&line<Tab>\\pl :call C_InsertTemplate("preprocessor.line")<CR>' + exe "imenu ".s:Preprocessor.'.#&line<Tab>\\pl <C-C>:call C_InsertTemplate("preprocessor.line")<CR>' + exe "amenu ".s:Preprocessor.'.#&pragma<Tab>\\pp :call C_InsertTemplate("preprocessor.pragma")<CR>' + exe "imenu ".s:Preprocessor.'.#&pragma<Tab>\\pp <C-C>:call C_InsertTemplate("preprocessor.pragma")<CR>' + " + "=============================================================================================== + "----- Menu : Snippets ---------------------------------------------------- {{{2 + "=============================================================================================== + " + if s:C_MenuHeader == 'yes' + exe "amenu ".s:Snippets.'.S&nippets<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Snippets.'.-Sep00- <Nop>' + endif + if s:C_CodeSnippets != "" + exe "amenu <silent> ".s:Snippets.'.&read\ code\ snippet<Tab>\\nr :call C_CodeSnippet("r")<CR>' + exe "imenu <silent> ".s:Snippets.'.&read\ code\ snippet<Tab>\\nr <C-C>:call C_CodeSnippet("r")<CR>' + exe "amenu <silent> ".s:Snippets.'.&write\ code\ snippet<Tab>\\nw :call C_CodeSnippet("w")<CR>' + exe "imenu <silent> ".s:Snippets.'.&write\ code\ snippet<Tab>\\nw <C-C>:call C_CodeSnippet("w")<CR>' + exe "vmenu <silent> ".s:Snippets.'.&write\ code\ snippet<Tab>\\nw <C-C>:call C_CodeSnippet("wv")<CR>' + exe "amenu <silent> ".s:Snippets.'.&edit\ code\ snippet<Tab>\\ne :call C_CodeSnippet("e")<CR>' + exe "imenu <silent> ".s:Snippets.'.&edit\ code\ snippet<Tab>\\ne <C-C>:call C_CodeSnippet("e")<CR>' + exe " menu <silent> ".s:Snippets.'.-SEP1- :' + endif + exe " menu <silent> ".s:Snippets.'.&pick\ up\ prototype<Tab>\\np :call C_ProtoPick("n")<CR>' + exe "imenu <silent> ".s:Snippets.'.&pick\ up\ prototype<Tab>\\np <C-C>:call C_ProtoPick("n")<CR>' + exe "vmenu <silent> ".s:Snippets.'.&pick\ up\ prototype<Tab>\\np <C-C>:call C_ProtoPick("v")<CR>' + exe " menu <silent> ".s:Snippets.'.&insert\ prototype(s)<Tab>\\ni :call C_ProtoInsert()<CR>' + exe "imenu <silent> ".s:Snippets.'.&insert\ prototype(s)<Tab>\\ni <C-C>:call C_ProtoInsert()<CR>' + exe " menu <silent> ".s:Snippets.'.&clear\ prototype(s)<Tab>\\nc :call C_ProtoClear()<CR>' + exe "imenu <silent> ".s:Snippets.'.&clear\ prototype(s)<Tab>\\nc <C-C>:call C_ProtoClear()<CR>' + exe " menu <silent> ".s:Snippets.'.&show\ prototype(s)<Tab>\\ns :call C_ProtoShow()<CR>' + exe "imenu <silent> ".s:Snippets.'.&show\ prototype(s)<Tab>\\ns <C-C>:call C_ProtoShow()<CR>' + + exe " menu <silent> ".s:Snippets.'.-SEP2- :' + exe "amenu <silent> ".s:Snippets.'.edit\ &local\ templates<Tab>\\ntl :call C_EditTemplates("local")<CR>' + exe "imenu <silent> ".s:Snippets.'.edit\ &local\ templates<Tab>\\ntl <C-C>:call C_EditTemplates("local")<CR>' + exe "amenu <silent> ".s:Snippets.'.edit\ &global\ templates<Tab>\\ntg :call C_EditTemplates("global")<CR>' + exe "imenu <silent> ".s:Snippets.'.edit\ &global\ templates<Tab>\\ntg <C-C>:call C_EditTemplates("global")<CR>' + exe "amenu <silent> ".s:Snippets.'.reread\ &templates<Tab>\\ntr :call C_RereadTemplates()<CR>' + exe "imenu <silent> ".s:Snippets.'.reread\ &templates<Tab>\\ntr <C-C>:call C_RereadTemplates()<CR>' + exe "amenu ".s:Snippets.'.switch\ template\ st&yle<Tab>\\nts :CStyle<Space>' + exe "imenu ".s:Snippets.'.switch\ template\ st&yle<Tab>\\nts <C-C>:CStyle<Space>' + " + "=============================================================================================== + "----- Menu : C++ --------------------------------------------------------- {{{2 + "=============================================================================================== + " + if s:C_MenuHeader == 'yes' + exe "amenu ".s:Cpp.'.C&\+\+<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Cpp.'.-Sep00- <Nop>' + endif + exe "anoremenu ".s:Cpp.'.c&in :call C_InsertTemplate("cpp.cin")<CR>' + exe "inoremenu ".s:Cpp.'.c&in <Esc>:call C_InsertTemplate("cpp.cin")<CR>' + exe "anoremenu ".s:Cpp.'.c&out<Tab>\\+co :call C_InsertTemplate("cpp.cout")<CR>' + exe "inoremenu ".s:Cpp.'.c&out<Tab>\\+co <Esc>:call C_InsertTemplate("cpp.cout")<CR>' + exe "anoremenu ".s:Cpp.'.<<\ &\"\" :call C_InsertTemplate("cpp.cout-operator")<CR>' + exe "inoremenu ".s:Cpp.'.<<\ &\"\" <Esc>:call C_InsertTemplate("cpp.cout-operator")<CR>' + " + "----- Submenu : C++ : output manipulators ------------------------------------------------------- + " + exe "amenu ".s:Cpp.'.&output\ manipulators.output\ manip\.<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Cpp.'.&output\ manipulators.-Sep0- <Nop>' + " + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &boolalpha :call C_InsertTemplate("cpp.output-manipulator-boolalpha")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &dec :call C_InsertTemplate("cpp.output-manipulator-dec")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &endl :call C_InsertTemplate("cpp.output-manipulator-endl")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &fixed :call C_InsertTemplate("cpp.output-manipulator-fixed")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ fl&ush :call C_InsertTemplate("cpp.output-manipulator-flush")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &hex :call C_InsertTemplate("cpp.output-manipulator-hex")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &internal :call C_InsertTemplate("cpp.output-manipulator-internal")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &left :call C_InsertTemplate("cpp.output-manipulator-left")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &oct :call C_InsertTemplate("cpp.output-manipulator-oct")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &right :call C_InsertTemplate("cpp.output-manipulator-right")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ s&cientific :call C_InsertTemplate("cpp.output-manipulator-scientific")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &setbase\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setbase")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ se&tfill\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setfill")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ setiosfla&g\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setiosflags")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ set&precision\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setprecision")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ set&w\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setw")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ showb&ase :call C_InsertTemplate("cpp.output-manipulator-showbase")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ showpoi&nt :call C_InsertTemplate("cpp.output-manipulator-showpoint")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ showpos\ \(&1\) :call C_InsertTemplate("cpp.output-manipulator-showpos")<CR>' + exe "anoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ uppercase\ \(&2\) :call C_InsertTemplate("cpp.output-manipulator-uppercase")<CR>' + " + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &boolalpha <Esc>:call C_InsertTemplate("cpp.output-manipulator-boolalpha")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &dec <Esc>:call C_InsertTemplate("cpp.output-manipulator-dec")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &endl <Esc>:call C_InsertTemplate("cpp.output-manipulator-endl")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &fixed <Esc>:call C_InsertTemplate("cpp.output-manipulator-fixed")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ fl&ush <Esc>:call C_InsertTemplate("cpp.output-manipulator-flush")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &hex <Esc>:call C_InsertTemplate("cpp.output-manipulator-hex")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &internal <Esc>:call C_InsertTemplate("cpp.output-manipulator-internal")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &left <Esc>:call C_InsertTemplate("cpp.output-manipulator-left")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &oct <Esc>:call C_InsertTemplate("cpp.output-manipulator-oct")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &right <Esc>:call C_InsertTemplate("cpp.output-manipulator-right")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ s&cientific <Esc>:call C_InsertTemplate("cpp.output-manipulator-scientific")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ &setbase\(\ \) <Esc>:call C_InsertTemplate("cpp.output-manipulator-setbase")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ se&tfill\(\ \) <Esc>:call C_InsertTemplate("cpp.output-manipulator-setfill")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ setiosfla&g\(\ \) <Esc>:call C_InsertTemplate("cpp.output-manipulator-setiosflags")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ set&precision\(\ \) <Esc>:call C_InsertTemplate("cpp.output-manipulator-setprecision")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ set&w\(\ \) <Esc>:call C_InsertTemplate("cpp.output-manipulator-setw")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ showb&ase <Esc>:call C_InsertTemplate("cpp.output-manipulator-showbase")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ showpoi&nt <Esc>:call C_InsertTemplate("cpp.output-manipulator-showpoint")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ showpos\ \(&1\) <Esc>:call C_InsertTemplate("cpp.output-manipulator-showpos")<CR>' + exe "inoremenu ".s:Cpp.'.&output\ manipulators.\<\<\ uppercase\ \(&2\) <Esc>:call C_InsertTemplate("cpp.output-manipulator-uppercase")<CR>' + " + "----- Submenu : C++ : ios flag bits ------------------------------------------------------------- + " + exe "amenu ".s:Cpp.'.ios\ flag&bits.ios\ flags<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Cpp.'.ios\ flag&bits.-Sep0- <Nop>' + " + call C_CIosFlagMenus ( s:Cpp.'.ios\ flag&bits', s:Cpp_IosFlagBits ) + " + "----- Submenu : C++ library (algorithm - locale) ---------------------------------------------- + " + exe "amenu ".s:Cpp.'.&#include\ <alg\.\.vec><Tab>\\+ps.alg\.\.vec<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Cpp.'.&#include\ <alg\.\.vec><Tab>\\+ps.-Sep0- <Nop>' + call C_CIncludeMenus ( s:Cpp.'.&#include\ <alg\.\.vec><Tab>\\+ps', s:Cpp_StandardLibs ) + " + "----- Submenu : C library (cassert - ctime) ------------------------------------------------- + " + exe "amenu ".s:Cpp.'.&#include\ <cX><Tab>\\+pc.cX<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Cpp.'.&#include\ <cX><Tab>\\+pc.-Sep0- <Nop>' + call C_CIncludeMenus ( s:Cpp.'.&#include\ <cX><Tab>\\+pc', s:Cpp_CStandardLibs ) + " + "----- End Submenu : C library (cassert - ctime) --------------------------------------------- + " + exe "amenu <silent> ".s:Cpp.'.-SEP2- :' + + exe "amenu <silent> ".s:Cpp.'.&class<Tab>\\+c :call C_InsertTemplate("cpp.class-definition")<CR>' + exe "imenu <silent> ".s:Cpp.'.&class<Tab>\\+c <Esc>:call C_InsertTemplate("cpp.class-definition")<CR>' + exe "amenu <silent> ".s:Cpp.'.class\ (w\.\ &new)<Tab>\\+cn :call C_InsertTemplate("cpp.class-using-new-definition")<CR>' + exe "imenu <silent> ".s:Cpp.'.class\ (w\.\ &new)<Tab>\\+cn <Esc>:call C_InsertTemplate("cpp.class-using-new-definition")<CR>' + exe "amenu <silent> ".s:Cpp.'.&templ\.\ class<Tab>\\+tc :call C_InsertTemplate("cpp.template-class-definition")<CR>' + exe "imenu <silent> ".s:Cpp.'.&templ\.\ class<Tab>\\+tc <Esc>:call C_InsertTemplate("cpp.template-class-definition")<CR>' + exe "amenu <silent> ".s:Cpp.'.templ\.\ class\ (w\.\ ne&w)<Tab>\\+tcn :call C_InsertTemplate("cpp.template-class-using-new-definition")<CR>' + exe "imenu <silent> ".s:Cpp.'.templ\.\ class\ (w\.\ ne&w)<Tab>\\+tcn <Esc>:call C_InsertTemplate("cpp.template-class-using-new-definition")<CR>' + + " + "----- Submenu : C++ : IMPLEMENTATION ------------------------------------------------------- + " + exe "amenu ".s:Cpp.'.IM&PLEMENTATION.IMPLEMENT\.<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Cpp.'.IM&PLEMENTATION.-Sep0- <Nop>' + " + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.&class<Tab>\\+ci :call C_InsertTemplate("cpp.class-implementation")<CR>' + exe "imenu <silent> ".s:Cpp.'.IM&PLEMENTATION.&class<Tab>\\+ci <Esc>:call C_InsertTemplate("cpp.class-implementation")<CR>' + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.class\ (w\.\ &new)<Tab>\\+cni :call C_InsertTemplate("cpp.class-using-new-implementation")<CR>' + exe "imenu <silent> ".s:Cpp.'.IM&PLEMENTATION.class\ (w\.\ &new)<Tab>\\+cni <Esc>:call C_InsertTemplate("cpp.class-using-new-implementation")<CR>' + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.&method<Tab>\\+mi :call C_InsertTemplate("cpp.method-implementation")<CR>' + exe "imenu <silent> ".s:Cpp.'.IM&PLEMENTATION.&method<Tab>\\+mi <Esc>:call C_InsertTemplate("cpp.method-implementation")<CR>' + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.&accessor<Tab>\\+ai :call C_InsertTemplate("cpp.accessor-implementation")<CR>' + exe "imenu <silent> ".s:Cpp.'.IM&PLEMENTATION.&accessor<Tab>\\+ai <Esc>:call C_InsertTemplate("cpp.accessor-implementation")<CR>' + " + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.-SEP21- :' + exe "imenu <silent> ".s:Cpp.'.IM&PLEMENTATION.&templ\.\ class<Tab>\\+tci <Esc>:call C_InsertTemplate("cpp.template-class-implementation")<CR>' + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.&templ\.\ class<Tab>\\+tci :call C_InsertTemplate("cpp.template-class-implementation")<CR>' + exe "imenu <silent> ".s:Cpp.'.IM&PLEMENTATION.templ\.\ class\ (w\.\ ne&w)<Tab>\\+tcni <Esc>:call C_InsertTemplate("cpp.template-class-using-new-implementation")<CR>' + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.templ\.\ class\ (w\.\ ne&w)<Tab>\\+tcni :call C_InsertTemplate("cpp.template-class-using-new-implementation")<CR>' + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.templ\.\ mðod<Tab>\\+tmi :call C_InsertTemplate("cpp.template-method-implementation")<CR>' + exe "imenu <silent> ".s:Cpp.'.IM&PLEMENTATION.templ\.\ mðod<Tab>\\+tmi <Esc>:call C_InsertTemplate("cpp.template-method-implementation")<CR>' + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.templ\.\ a&ccessor<Tab>\\+tai :call C_InsertTemplate("cpp.template-accessor-implementation")<CR>' + exe "imenu <silent> ".s:Cpp.'.IM&PLEMENTATION.templ\.\ a&ccessor<Tab>\\+tai <Esc>:call C_InsertTemplate("cpp.template-accessor-implementation")<CR>' + " + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.-SEP22- :' + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.operator\ &<< :call C_InsertTemplate("cpp.operator-in")<CR>' + exe "imenu <silent> ".s:Cpp.'.IM&PLEMENTATION.operator\ &<< <Esc>:call C_InsertTemplate("cpp.operator-in")<CR>' + exe "amenu <silent> ".s:Cpp.'.IM&PLEMENTATION.operator\ &>> :call C_InsertTemplate("cpp.operator-out")<CR>' + exe "imenu <silent> ".s:Cpp.'.IM&PLEMENTATION.operator\ &>> <Esc>:call C_InsertTemplate("cpp.operator-out")<CR>' + " + "----- End Submenu : C++ : IMPLEMENTATION ------------------------------------------------------- + " + exe "amenu <silent> ".s:Cpp.'.-SEP31- :' + exe "amenu <silent> ".s:Cpp.'.templ\.\ &function<Tab>\\+tf :call C_InsertTemplate("cpp.template-function")<CR>' + exe "imenu <silent> ".s:Cpp.'.templ\.\ &function<Tab>\\+tf <Esc>:call C_InsertTemplate("cpp.template-function")<CR>' + exe "amenu <silent> ".s:Cpp.'.&error\ class<Tab>\\+ec :call C_InsertTemplate("cpp.error-class")<CR>' + exe "imenu <silent> ".s:Cpp.'.&error\ class<Tab>\\+ec <Esc>:call C_InsertTemplate("cpp.error-class")<CR>' + + exe "amenu <silent> ".s:Cpp.'.-SEP5- :' + exe "amenu <silent> ".s:Cpp.'.tr&y\ \.\.\ catch<Tab>\\+tr :call C_InsertTemplate("cpp.try-catch")<CR>' + exe "imenu <silent> ".s:Cpp.'.tr&y\ \.\.\ catch<Tab>\\+tr <Esc>:call C_InsertTemplate("cpp.try-catch")<CR>' + exe "vmenu <silent> ".s:Cpp.'.tr&y\ \.\.\ catch<Tab>\\+tr <Esc>:call C_InsertTemplate("cpp.try-catch", "v")<CR>' + exe "amenu <silent> ".s:Cpp.'.catc&h<Tab>\\+ca :call C_InsertTemplate("cpp.catch")<CR>' + exe "imenu <silent> ".s:Cpp.'.catc&h<Tab>\\+ca <Esc>:call C_InsertTemplate("cpp.catch")<CR>' + exe "vmenu <silent> ".s:Cpp.'.catc&h<Tab>\\+ca <Esc>:call C_InsertTemplate("cpp.catch", "v")<CR>' + + exe "amenu <silent> ".s:Cpp.'.catch\(&\.\.\.\)<Tab>\\+c\. :call C_InsertTemplate("cpp.catch-points")<CR>' + exe "imenu <silent> ".s:Cpp.'.catch\(&\.\.\.\)<Tab>\\+c\. <Esc>:call C_InsertTemplate("cpp.catch-points")<CR>' + exe "vmenu <silent> ".s:Cpp.'.catch\(&\.\.\.\)<Tab>\\+c\. <Esc>:call C_InsertTemplate("cpp.catch-points", "v")<CR>' + + exe "amenu <silent> ".s:Cpp.'.-SEP6- :' + exe "amenu <silent> ".s:Cpp.'.open\ input\ file\ \ \(&4\) :call C_InsertTemplate("cpp.open-input-file")<CR>' + exe "imenu <silent> ".s:Cpp.'.open\ input\ file\ \ \(&4\) <Esc>:call C_InsertTemplate("cpp.open-input-file")<CR>' + exe "vmenu <silent> ".s:Cpp.'.open\ input\ file\ \ \(&4\) <Esc>:call C_InsertTemplate("cpp.open-input-file", "v")<CR>' + exe "amenu <silent> ".s:Cpp.'.open\ output\ file\ \(&5\) :call C_InsertTemplate("cpp.open-output-file")<CR>' + exe "imenu <silent> ".s:Cpp.'.open\ output\ file\ \(&5\) <Esc>:call C_InsertTemplate("cpp.open-output-file")<CR>' + exe "vmenu <silent> ".s:Cpp.'.open\ output\ file\ \(&5\) <Esc>:call C_InsertTemplate("cpp.open-output-file", "v")<CR>' + exe "amenu <silent> ".s:Cpp.'.-SEP7- :' + + exe "amenu <silent> ".s:Cpp.'.&using\ namespace\ std; :call C_InsertTemplate("cpp.namespace-std")<CR>' + exe "imenu <silent> ".s:Cpp.'.&using\ namespace\ std; <Esc>:call C_InsertTemplate("cpp.namespace-std")<CR>' + exe "amenu <silent> ".s:Cpp.'.u&sing\ namespace\ ???; :call C_InsertTemplate("cpp.namespace")<CR>' + exe "imenu <silent> ".s:Cpp.'.u&sing\ namespace\ ???; <Esc>:call C_InsertTemplate("cpp.namespace")<CR>' + + exe "amenu <silent> ".s:Cpp.'.names&pace\ ???\ \{\ \} :call C_InsertTemplate("cpp.namespace-block")<CR>' + exe "imenu <silent> ".s:Cpp.'.names&pace\ ???\ \{\ \} <Esc>:call C_InsertTemplate("cpp.namespace-block")<CR>' + exe "vmenu <silent> ".s:Cpp.'.names&pace\ ???\ \{\ \} <Esc>:call C_InsertTemplate("cpp.namespace-block", "v")<CR>' + exe "amenu <silent> ".s:Cpp.'.namespace\ &alias\ =\ ??? :call C_InsertTemplate("cpp.namespace-alias")<CR>' + exe "imenu <silent> ".s:Cpp.'.namespace\ &alias\ =\ ??? <Esc>:call C_InsertTemplate("cpp.namespace-alias")<CR>' + + exe "amenu <silent> ".s:Cpp.'.-SEP8- :' + " + "----- Submenu : RTTI ---------------------------------------------------------------------------- + " + exe "amenu ".s:Cpp.'.&RTTI.RTTI<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Cpp.'.&RTTI.-Sep0- <Nop>' + " + exe "anoremenu ".s:Cpp.'.&RTTI.&typeid :call C_InsertTemplate("cpp.rtti-typeid")<CR>' + exe "anoremenu ".s:Cpp.'.&RTTI.&static_cast :call C_InsertTemplate("cpp.rtti-static-cast")<CR>' + exe "anoremenu ".s:Cpp.'.&RTTI.&const_cast :call C_InsertTemplate("cpp.rtti-const-cast")<CR>' + exe "anoremenu ".s:Cpp.'.&RTTI.&reinterpret_cast :call C_InsertTemplate("cpp.rtti-reinterpret-cast")<CR>' + exe "anoremenu ".s:Cpp.'.&RTTI.&dynamic_cast :call C_InsertTemplate("cpp.rtti-dynamic-cast")<CR>' + " + exe "inoremenu ".s:Cpp.'.&RTTI.&typeid <Esc>:call C_InsertTemplate("cpp.rtti-typeid")<CR>' + exe "inoremenu ".s:Cpp.'.&RTTI.&static_cast <Esc>:call C_InsertTemplate("cpp.rtti-static-cast")<CR>' + exe "inoremenu ".s:Cpp.'.&RTTI.&const_cast <Esc>:call C_InsertTemplate("cpp.rtti-const-cast")<CR>' + exe "inoremenu ".s:Cpp.'.&RTTI.&reinterpret_cast <Esc>:call C_InsertTemplate("cpp.rtti-reinterpret-cast")<CR>' + exe "inoremenu ".s:Cpp.'.&RTTI.&dynamic_cast <Esc>:call C_InsertTemplate("cpp.rtti-dynamic-cast")<CR>' + " + exe "vnoremenu ".s:Cpp.'.&RTTI.&typeid <Esc>:call C_InsertTemplate("cpp.rtti-typeid", "v")<CR>' + exe "vnoremenu ".s:Cpp.'.&RTTI.&static_cast <Esc>:call C_InsertTemplate("cpp.rtti-static-cast", "v")<CR>' + exe "vnoremenu ".s:Cpp.'.&RTTI.&const_cast <Esc>:call C_InsertTemplate("cpp.rtti-const-cast", "v")<CR>' + exe "vnoremenu ".s:Cpp.'.&RTTI.&reinterpret_cast <Esc>:call C_InsertTemplate("cpp.rtti-reinterpret-cast", "v")<CR>' + exe "vnoremenu ".s:Cpp.'.&RTTI.&dynamic_cast <Esc>:call C_InsertTemplate("cpp.rtti-dynamic-cast", "v")<CR>' + " + "----- End Submenu : RTTI ------------------------------------------------------------------------ + " + exe "amenu <silent>".s:Cpp.'.e&xtern\ \"C\"\ \{\ \} :call C_InsertTemplate("cpp.extern")<CR>' + exe "imenu <silent>".s:Cpp.'.e&xtern\ \"C\"\ \{\ \} <Esc>:call C_InsertTemplate("cpp.extern")<CR>' + exe "vmenu <silent>".s:Cpp.'.e&xtern\ \"C\"\ \{\ \} <Esc>:call C_InsertTemplate("cpp.extern", "v")<CR>' + " + "=============================================================================================== + "----- Menu : run ----- -------------------------------------------------- {{{2 + "=============================================================================================== + " + if s:C_MenuHeader == 'yes' + exe "amenu ".s:Run.'.&Run<Tab>C\/C\+\+ <Nop>' + exe "amenu ".s:Run.'.-Sep00- <Nop>' + endif + " + exe "amenu <silent> ".s:Run.'.save\ and\ &compile<Tab>\\rc\ \ \<A-F9\> :call C_Compile()<CR>:call C_HlMessage()<CR>' + exe "imenu <silent> ".s:Run.'.save\ and\ &compile<Tab>\\rc\ \ \<A-F9\> <C-C>:call C_Compile()<CR>:call C_HlMessage()<CR>' + exe "amenu <silent> ".s:Run.'.&link<Tab>\\rl\ \ \ \ \<F9\> :call C_Link()<CR>:call C_HlMessage()<CR>' + exe "imenu <silent> ".s:Run.'.&link<Tab>\\rl\ \ \ \ \<F9\> <C-C>:call C_Link()<CR>:call C_HlMessage()<CR>' + exe "amenu <silent> ".s:Run.'.&run<Tab>\\rr\ \ \<C-F9\> :call C_Run()<CR>' + exe "imenu <silent> ".s:Run.'.&run<Tab>\\rr\ \ \<C-F9\> <C-C>:call C_Run()<CR>' + exe "amenu <silent> ".s:Run.'.cmd\.\ line\ &arg\.<Tab>\\ra\ \ \<S-F9\> :call C_Arguments()<CR>' + exe "imenu <silent> ".s:Run.'.cmd\.\ line\ &arg\.<Tab>\\ra\ \ \<S-F9\> <C-C>:call C_Arguments()<CR>' + " + exe "amenu <silent> ".s:Run.'.-SEP0- :' + exe "amenu <silent> ".s:Run.'.&make<Tab>\\rm :call C_Make()<CR>' + exe "imenu <silent> ".s:Run.'.&make<Tab>\\rm <C-C>:call C_Make()<CR>' + exe "amenu <silent> ".s:Run.'.cmd\.\ line\ ar&g\.\ for\ make<Tab>\\rg :call C_MakeArguments()<CR>' + exe "imenu <silent> ".s:Run.'.cmd\.\ line\ ar&g\.\ for\ make<Tab>\\rg <C-C>:call C_MakeArguments()<CR>' + " + exe "amenu <silent> ".s:Run.'.-SEP1- :' + " + if s:C_SplintIsExecutable==1 + exe "amenu <silent> ".s:Run.'.s&plint<Tab>\\rp :call C_SplintCheck()<CR>:call C_HlMessage()<CR>' + exe "imenu <silent> ".s:Run.'.s&plint<Tab>\\rp <C-C>:call C_SplintCheck()<CR>:call C_HlMessage()<CR>' + exe "amenu <silent> ".s:Run.'.cmd\.\ line\ arg\.\ for\ spl&int<Tab>\\ri :call C_SplintArguments()<CR>' + exe "imenu <silent> ".s:Run.'.cmd\.\ line\ arg\.\ for\ spl&int<Tab>\\ri <C-C>:call C_SplintArguments()<CR>' + exe "amenu <silent> ".s:Run.'.-SEP2- :' + endif + " + if s:C_CodeCheckIsExecutable==1 + exe "amenu <silent> ".s:Run.'.CodeChec&k<Tab>\\rk :call C_CodeCheck()<CR>:call C_HlMessage()<CR>' + exe "imenu <silent> ".s:Run.'.CodeChec&k<Tab>\\rk <C-C>:call C_CodeCheck()<CR>:call C_HlMessage()<CR>' + exe "amenu <silent> ".s:Run.'.cmd\.\ line\ arg\.\ for\ Cod&eCheck<Tab>\\re :call C_CodeCheckArguments()<CR>' + exe "imenu <silent> ".s:Run.'.cmd\.\ line\ arg\.\ for\ Cod&eCheck<Tab>\\re <C-C>:call C_CodeCheckArguments()<CR>' + exe "amenu <silent> ".s:Run.'.-SEP3- :' + endif + " + exe "amenu <silent> ".s:Run.'.in&dent<Tab>\\rd :call C_Indent()<CR>' + exe "imenu <silent> ".s:Run.'.in&dent<Tab>\\rd <C-C>:call C_Indent()<CR>' + if s:MSWIN + exe "amenu <silent> ".s:Run.'.&hardcopy\ to\ printer<Tab>\\rh :call C_Hardcopy("n")<CR>' + exe "imenu <silent> ".s:Run.'.&hardcopy\ to\ printer<Tab>\\rh <C-C>:call C_Hardcopy("n")<CR>' + exe "vmenu <silent> ".s:Run.'.&hardcopy\ to\ printer<Tab>\\rh <C-C>:call C_Hardcopy("v")<CR>' + else + exe "amenu <silent> ".s:Run.'.&hardcopy\ to\ FILENAME\.ps<Tab>\\rh :call C_Hardcopy("n")<CR>' + exe "imenu <silent> ".s:Run.'.&hardcopy\ to\ FILENAME\.ps<Tab>\\rh <C-C>:call C_Hardcopy("n")<CR>' + exe "vmenu <silent> ".s:Run.'.&hardcopy\ to\ FILENAME\.ps<Tab>\\rh <C-C>:call C_Hardcopy("v")<CR>' + endif + exe "imenu <silent> ".s:Run.'.-SEP4- :' + + exe "amenu <silent> ".s:Run.'.&settings<Tab>\\rs :call C_Settings()<CR>' + exe "imenu <silent> ".s:Run.'.&settings<Tab>\\rs <C-C>:call C_Settings()<CR>' + exe "imenu <silent> ".s:Run.'.-SEP5- :' + + if !s:MSWIN + exe "amenu <silent> ".s:Run.'.&xterm\ size<Tab>\\rx :call C_XtermSize()<CR>' + exe "imenu <silent> ".s:Run.'.&xterm\ size<Tab>\\rx <C-C>:call C_XtermSize()<CR>' + endif + if s:C_OutputGvim == "vim" + exe "amenu <silent> ".s:Run.'.&output:\ VIM->buffer->xterm<Tab>\\ro :call C_Toggle_Gvim_Xterm()<CR><CR>' + exe "imenu <silent> ".s:Run.'.&output:\ VIM->buffer->xterm<Tab>\\ro <C-C>:call C_Toggle_Gvim_Xterm()<CR><CR>' + else + if s:C_OutputGvim == "buffer" + exe "amenu <silent> ".s:Run.'.&output:\ BUFFER->xterm->vim<Tab>\\ro :call C_Toggle_Gvim_Xterm()<CR><CR>' + exe "imenu <silent> ".s:Run.'.&output:\ BUFFER->xterm->vim<Tab>\\ro <C-C>:call C_Toggle_Gvim_Xterm()<CR><CR>' + else + exe "amenu <silent> ".s:Run.'.&output:\ XTERM->vim->buffer<Tab>\\ro :call C_Toggle_Gvim_Xterm()<CR><CR>' + exe "imenu <silent> ".s:Run.'.&output:\ XTERM->vim->buffer<Tab>\\ro <C-C>:call C_Toggle_Gvim_Xterm()<CR><CR>' + endif + endif + " + "=============================================================================================== + "----- Menu : help ------------------------------------------------------- {{{2 + "=============================================================================================== + " + if s:C_Root != "" + exe " menu <silent> ".s:C_Root.'&help\ (C-Support)<Tab>\\hp :call C_HelpCsupport()<CR>' + exe "imenu <silent> ".s:C_Root.'&help\ (C-Support)<Tab>\\hp <C-C>:call C_HelpCsupport()<CR>' + exe " menu <silent> ".s:C_Root.'show\ &manual<Tab>\\hm :call C_Help("m")<CR>' + exe "imenu <silent> ".s:C_Root.'show\ &manual<Tab>\\hm <C-C>:call C_Help("m")<CR>' + endif + +endfunction " ---------- end of function C_InitMenus ---------- +" +"=============================================================================================== +"----- Menu Functions -------------------------------------------------------------------------- +"=============================================================================================== +" +let s:C_StandardLibs = [ + \ '&assert\.h' , '&ctype\.h' , '&errno\.h' , + \ '&float\.h' , '&limits\.h' , 'l&ocale\.h' , + \ '&math\.h' , 'set&jmp\.h' , 's&ignal\.h' , + \ 'stdar&g\.h' , 'st&ddef\.h' , '&stdio\.h' , + \ 'stdli&b\.h' , 'st&ring\.h' , '&time\.h' , + \ ] +" +let s:C_C99Libs = [ + \ '&complex\.h', '&fenv\.h', '&inttypes\.h', + \ 'is&o646\.h', '&stdbool\.h', 's&tdint\.h', + \ 'tg&math\.h', '&wchar\.h', 'wct&ype\.h', + \ ] +" +let s:Cpp_StandardLibs = [ + \ '&algorithm', '&bitset', '&complex', '&deque', + \ '&exception', '&fstream', 'f&unctional', 'iomani&p', + \ '&ios', 'iosf&wd', 'io&stream', 'istrea&m', + \ 'iterato&r', '&limits', 'lis&t', 'l&ocale', + \ '&map', 'memor&y', '&new', 'numeri&c', + \ '&ostream', '&queue', '&set', 'sst&ream', + \ 'st&ack', 'stde&xcept', 'stream&buf', 'str&ing', + \ '&typeinfo', '&utility', '&valarray', 'v&ector', + \ ] +" +let s:Cpp_CStandardLibs = [ + \ 'c&assert', 'c&ctype', 'c&errno', 'c&float', + \ 'c&limits', 'cl&ocale', 'c&math', 'cset&jmp', + \ 'cs&ignal', 'cstdar&g', 'cst&ddef', 'c&stdio', + \ 'cstdli&b', 'cst&ring', 'c&time', + \ ] + +let s:Cpp_IosFlagBits = [ + \ 'ios::&adjustfield', 'ios::bas&efield', 'ios::&boolalpha', + \ 'ios::&dec', 'ios::&fixed', 'ios::floa&tfield', + \ 'ios::&hex', 'ios::&internal', 'ios::&left', + \ 'ios::&oct', 'ios::&right', 'ios::s&cientific', + \ 'ios::sho&wbase', 'ios::showpoint\ \(&1\)', 'ios::show&pos', + \ 'ios::&skipws', 'ios::u&nitbuf', 'ios::&uppercase', + \ ] + +"------------------------------------------------------------------------------ +" C_CIncludeMenus: generate the C/C++-standard library menu entries {{{1 +"------------------------------------------------------------------------------ +function! C_CIncludeMenus ( menupath, liblist ) + for item in a:liblist + let replacement = substitute( item, '[&\\]*', '','g' ) + exe "anoremenu ".a:menupath.'.'.item.' o#include<Tab><'.replacement.'>' + exe "inoremenu ".a:menupath.'.'.item.' <Esc>o#include<Tab><'.replacement.'>' + endfor + return +endfunction " ---------- end of function C_CIncludeMenus ---------- + +"------------------------------------------------------------------------------ +" C_CIosFlagMenus: generate the C++ ios flags menu entries {{{1 +"------------------------------------------------------------------------------ +function! C_CIosFlagMenus ( menupath, flaglist ) + for item in a:flaglist + let replacement = substitute( item, '[^[:alpha:]:]', '','g' ) + exe " noremenu ".a:menupath.'.'.item.' i'.replacement + exe "inoremenu ".a:menupath.'.'.item.' '.replacement + endfor + return +endfunction " ---------- end of function C_CIosFlagMenus ---------- +" +"------------------------------------------------------------------------------ +" C_Input: Input after a highlighted prompt {{{1 +"------------------------------------------------------------------------------ +function! C_Input ( promp, text, ... ) + echohl Search " highlight prompt + call inputsave() " preserve typeahead + if a:0 == 0 || a:1 == '' + let retval =input( a:promp, a:text ) + else + let retval =input( a:promp, a:text, a:1 ) + endif + call inputrestore() " restore typeahead + echohl None " reset highlighting + let retval = substitute( retval, '^\s\+', "", "" ) " remove leading whitespaces + let retval = substitute( retval, '\s\+$', "", "" ) " remove trailing whitespaces + return retval +endfunction " ---------- end of function C_Input ---------- +" +"------------------------------------------------------------------------------ +" C_AdjustLineEndComm: adjust line-end comments {{{1 +"------------------------------------------------------------------------------ +" +" C comment or C++ comment: +let s:c_cppcomment= '\(\/\*.\{-}\*\/\|\/\/.*$\)' + +function! C_AdjustLineEndComm ( mode ) range + " + if !exists("b:C_LineEndCommentColumn") + let b:C_LineEndCommentColumn = s:C_LineEndCommColDefault + endif + + let save_cursor = getpos(".") + + let save_expandtab = &expandtab + exe ":set expandtab" + + if a:mode == 'v' + let pos0 = line("'<") + let pos1 = line("'>") + else + let pos0 = line(".") + let pos1 = pos0 + endif + + let linenumber = pos0 + exe ":".pos0 + + while linenumber <= pos1 + let line= getline(".") + + " line is not a pure comment but contains one + " + if match( line, '^\s*'.s:c_cppcomment ) < 0 && match( line, s:c_cppcomment ) > 0 + " + " disregard comments starting in a string + " + let idx1 = -1 + let idx2 = -1 + let commentstart= -2 + let commentend = 0 + while commentstart < idx2 && idx2 < commentend + let start = commentend + let idx2 = match( line, s:c_cppcomment, start ) + let commentstart= match ( line, '"[^"]\+"', start ) + let commentend = matchend( line, '"[^"]\+"', start ) + endwhile + " + " try to adjust the comment + " + let idx1 = 1 + match( line, '\s*'.s:c_cppcomment, start ) + let idx2 = 1 + idx2 + call setpos(".", [ 0, linenumber, idx1, 0 ] ) + let vpos1 = virtcol(".") + call setpos(".", [ 0, linenumber, idx2, 0 ] ) + let vpos2 = virtcol(".") + + if ! ( vpos2 == b:C_LineEndCommentColumn + \ || vpos1 > b:C_LineEndCommentColumn + \ || idx2 == 0 ) + + exe ":.,.retab" + " insert some spaces + if vpos2 < b:C_LineEndCommentColumn + let diff = b:C_LineEndCommentColumn-vpos2 + call setpos(".", [ 0, linenumber, vpos2, 0 ] ) + let @" = ' ' + exe "normal ".diff."P" + endif + + " remove some spaces + if vpos1 < b:C_LineEndCommentColumn && vpos2 > b:C_LineEndCommentColumn + let diff = vpos2 - b:C_LineEndCommentColumn + call setpos(".", [ 0, linenumber, b:C_LineEndCommentColumn, 0 ] ) + exe "normal ".diff."x" + endif + + endif + endif + let linenumber=linenumber+1 + normal j + endwhile + " + " restore tab expansion settings and cursor position + let &expandtab = save_expandtab + call setpos('.', save_cursor) + +endfunction " ---------- end of function C_AdjustLineEndComm ---------- +" +"------------------------------------------------------------------------------ +" C_GetLineEndCommCol: get line-end comment position {{{1 +"------------------------------------------------------------------------------ +function! C_GetLineEndCommCol () + let actcol = virtcol(".") + if actcol+1 == virtcol("$") + let b:C_LineEndCommentColumn = '' + while match( b:C_LineEndCommentColumn, '^\s*\d\+\s*$' ) < 0 + let b:C_LineEndCommentColumn = C_Input( 'start line-end comment at virtual column : ', actcol, '' ) + endwhile + else + let b:C_LineEndCommentColumn = virtcol(".") + endif + echomsg "line end comments will start at column ".b:C_LineEndCommentColumn +endfunction " ---------- end of function C_GetLineEndCommCol ---------- +" +"------------------------------------------------------------------------------ +" C_LineEndComment: single line-end comment {{{1 +"------------------------------------------------------------------------------ +function! C_LineEndComment ( ) + if !exists("b:C_LineEndCommentColumn") + let b:C_LineEndCommentColumn = s:C_LineEndCommColDefault + endif + " ----- trim whitespaces ----- + exe 's/\s*$//' + let linelength= virtcol("$") - 1 + if linelength < b:C_LineEndCommentColumn + let diff = b:C_LineEndCommentColumn -1 -linelength + exe "normal ".diff."A " + endif + " append at least one blank + if linelength >= b:C_LineEndCommentColumn + exe "normal A " + endif + call C_InsertTemplate('comment.end-of-line-comment') +endfunction " ---------- end of function C_LineEndComment ---------- +" +"------------------------------------------------------------------------------ +" C_MultiLineEndComments: multi line-end comments {{{1 +"------------------------------------------------------------------------------ +function! C_MultiLineEndComments ( ) + " + if !exists("b:C_LineEndCommentColumn") + let b:C_LineEndCommentColumn = s:C_LineEndCommColDefault + endif + " + let pos0 = line("'<") + let pos1 = line("'>") + " + " ----- trim whitespaces ----- + exe pos0.','.pos1.'s/\s*$//' + " + " ----- find the longest line ----- + let maxlength = 0 + normal '< + for linenumber in range( pos0, pos1 ) + if getline(linenumber) !~ '^\s*$' && maxlength<virtcol("$") + let maxlength= virtcol("$") + endif + endfor + " + if maxlength < b:C_LineEndCommentColumn + let maxlength = b:C_LineEndCommentColumn + else + let maxlength = maxlength+1 " at least 1 blank + endif + " + " ----- fill lines with blanks ----- + for linenumber in range( pos0, pos1 ) + exe ":".linenumber + if getline(linenumber) !~ '^\s*$' + let diff = maxlength - virtcol("$") + exe "normal ".diff."A " + call C_InsertTemplate('comment.end-of-line-comment') + endif + endfor + " + " ----- back to the begin of the marked block ----- + stopinsert + normal '<$ + if match( getline("."), '\/\/\s*$' ) < 0 + if search( '\/\*', 'bcW', line(".") ) > 1 + normal l + endif + let save_cursor = getpos(".") + if getline(".")[save_cursor[2]+1] == ' ' + normal l + endif + else + normal $ + endif +endfunction " ---------- end of function C_MultiLineEndComments ---------- +" +"------------------------------------------------------------------------------ +" C_Comment_C_SectionAll: Section Comments {{{1 +"------------------------------------------------------------------------------ +" +function! C_Comment_C_SectionAll ( type ) + + call C_InsertTemplate("comment.file-section-cpp-header-includes") + call C_InsertTemplate("comment.file-section-cpp-macros") + call C_InsertTemplate("comment.file-section-cpp-typedefs") + call C_InsertTemplate("comment.file-section-cpp-data-types") + if a:type=="cpp" + call C_InsertTemplate("comment.file-section-cpp-class-defs") + endif + call C_InsertTemplate("comment.file-section-cpp-local-variables") + call C_InsertTemplate("comment.file-section-cpp-prototypes") + call C_InsertTemplate("comment.file-section-cpp-function-defs-exported") + call C_InsertTemplate("comment.file-section-cpp-function-defs-local") + if a:type=="cpp" + call C_InsertTemplate("comment.file-section-cpp-class-implementations-exported") + call C_InsertTemplate("comment.file-section-cpp-class-implementations-local") + endif + +endfunction " ---------- end of function C_Comment_C_SectionAll ---------- +" +function! C_Comment_H_SectionAll ( type ) + + call C_InsertTemplate("comment.file-section-hpp-header-includes") + call C_InsertTemplate("comment.file-section-hpp-macros") + call C_InsertTemplate("comment.file-section-hpp-exported-typedefs") + call C_InsertTemplate("comment.file-section-hpp-exported-data-types") + if a:type=="cpp" + call C_InsertTemplate("comment.file-section-hpp-exported-class-defs") + endif + call C_InsertTemplate("comment.file-section-hpp-exported-variables") + call C_InsertTemplate("comment.file-section-hpp-exported-function-declarations") + +endfunction " ---------- end of function C_Comment_H_SectionAll ---------- +" +"---------------------------------------------------------------------- +" C_CodeComment : Code -> Comment {{{1 +"---------------------------------------------------------------------- +function! C_CodeComment( mode, style ) + + if a:mode=="a" + if a:style == 'yes' + silent exe ":s#^#/\* #" + silent put = ' */' + else + silent exe ":s#^#//#" + endif + endif + + if a:mode=="v" + if a:style == 'yes' + silent exe ":'<,'>s/^/ \* /" + silent exe ":'< s'^ '\/'" + silent exe ":'>" + silent put = ' */' + else + silent exe ":'<,'>s#^#//#" + endif + endif + +endfunction " ---------- end of function C_CodeComment ---------- +" +"---------------------------------------------------------------------- +" C_StartMultilineComment : Comment -> Code {{{1 +"---------------------------------------------------------------------- +let s:C_StartMultilineComment = '^\s*\/\*[\*! ]\=' + +function! C_RemoveCComment( start, end ) + + if a:end-a:start<1 + return 0 " lines removed + endif + " + " Is the C-comment complete ? Get length. + " + let check = getline( a:start ) =~ s:C_StartMultilineComment + let linenumber = a:start+1 + while linenumber < a:end && getline( linenumber ) !~ '^\s*\*\/' + let check = check && getline( linenumber ) =~ '^\s*\*[ ]\=' + let linenumber = linenumber+1 + endwhile + let check = check && getline( linenumber ) =~ '^\s*\*\/' + " + " remove a complete comment + " + if check + exe "silent :".a:start.' s/'.s:C_StartMultilineComment.'//' + let linenumber1 = a:start+1 + while linenumber1 < linenumber + exe "silent :".linenumber1.' s/^\s*\*[ ]\=//' + let linenumber1 = linenumber1+1 + endwhile + exe "silent :".linenumber1.' s/^\s*\*\///' + endif + + return linenumber-a:start+1 " lines removed +endfunction " ---------- end of function C_RemoveCComment ---------- +" +"---------------------------------------------------------------------- +" C_CommentCode : Comment -> Code {{{1 +"---------------------------------------------------------------------- +function! C_CommentCode(mode) + if a:mode=="a" + let pos1 = line(".") + let pos2 = pos1 + endif + if a:mode=="v" + let pos1 = line("'<") + let pos2 = line("'>") + endif + + let removed = 0 + " + let linenumber=pos1 + while linenumber <= pos2 + " Do we have a C++ comment ? + if getline( linenumber ) =~ '^\s*//' + exe "silent :".linenumber.' s#^\s*//##' + let removed = 1 + endif + " Do we have a C comment ? + if removed == 0 && getline( linenumber ) =~ s:C_StartMultilineComment + let removed = C_RemoveCComment(linenumber,pos2) + endif + + if removed!=0 + let linenumber = linenumber+removed + let removed = 0 + else + let linenumber = linenumber+1 + endif + endwhile +endfunction " ---------- end of function C_CommentCode ---------- +" +"---------------------------------------------------------------------- +" C_CommentCppToC : C++ Comment -> C Comment {{{1 +" Removes trailing whitespaces. +"---------------------------------------------------------------------- +function! C_CommentCppToC() + silent! exe ':s#\/\/\s*\(.*\)\s*$#/* \1 */#' +endfunction " ---------- end of function C_CommentCppToC ---------- +" +"---------------------------------------------------------------------- +" C_CommentCToCpp : C Comment -> C++ Comment {{{1 +" Changes the first comment in case of multiple comments: +" xxxx; /* */ /* */ +" xxxx; // /* */ +" Removes trailing whitespaces. +"---------------------------------------------------------------------- +function! C_CommentCToCpp() + silent! exe ':s!\/\*\s*\(.\{-}\)\*\/!\/\/ \1!' + silent! exe ':s!\s*$!!' +endfunction " ---------- end of function C_CommentCToCpp ---------- +" +"===================================================================================== +"----- Menu : Statements ----------------------------------------------------------- +"===================================================================================== +" +"------------------------------------------------------------------------------ +" C_PPIf0 : #if 0 .. #endif {{{1 +"------------------------------------------------------------------------------ +function! C_PPIf0 (mode) + " + let s:C_If0_Counter = 0 + let save_line = line(".") + let actual_line = 0 + " + " search for the maximum option number (if any) + " + normal gg + while actual_line < search( s:C_If0_Txt."\\d\\+" ) + let actual_line = line(".") + let actual_opt = matchstr( getline(actual_line), s:C_If0_Txt."\\d\\+" ) + let actual_opt = strpart( actual_opt, strlen(s:C_If0_Txt),strlen(actual_opt)-strlen(s:C_If0_Txt)) + if s:C_If0_Counter < actual_opt + let s:C_If0_Counter = actual_opt + endif + endwhile + let s:C_If0_Counter = s:C_If0_Counter+1 + silent exe ":".save_line + " + if a:mode=='a' + let zz= "\n#if 0 ".s:C_Com1." ----- #if 0 : ".s:C_If0_Txt.s:C_If0_Counter." ----- ".s:C_Com2."\n" + let zz= zz."\n#endif ".s:C_Com1." ----- #if 0 : ".s:C_If0_Txt.s:C_If0_Counter." ----- ".s:C_Com2."\n\n" + put =zz + normal 4k + endif + + if a:mode=='v' + let pos1 = line("'<") + let pos2 = line("'>") + let zz= "#endif ".s:C_Com1." ----- #if 0 : ".s:C_If0_Txt.s:C_If0_Counter." ----- ".s:C_Com2."\n\n" + exe ":".pos2."put =zz" + let zz= "\n#if 0 ".s:C_Com1." ----- #if 0 : ".s:C_If0_Txt.s:C_If0_Counter." ----- ".s:C_Com2."\n" + exe ":".pos1."put! =zz" + " + if &foldenable && foldclosed(".") + normal zv + endif + endif + +endfunction " ---------- end of function C_PPIf0 ---------- +" +"------------------------------------------------------------------------------ +" C_PPIf0Remove : remove #if 0 .. #endif {{{1 +"------------------------------------------------------------------------------ +function! C_PPIf0Remove () + " + " cursor on fold: open fold first + if &foldenable && foldclosed(".") + normal zv + endif + " + let frstline = searchpair( '^\s*#if\s\+0', '', '^\s*#endif\>.\+\<If0Label_', 'bn' ) + if frstline<=0 + echohl WarningMsg | echo 'no #if 0 ... #endif found or cursor not inside such a directive'| echohl None + return + endif + let lastline = searchpair( '^\s*#if\s\+0', '', '^\s*#endif\>.\+\<If0Label_', 'n' ) + if lastline<=0 + echohl WarningMsg | echo 'no #if 0 ... #endif found or cursor not inside such a directive'| echohl None + return + endif + let actualnumber1 = matchstr( getline(frstline), s:C_If0_Txt."\\d\\+" ) + let actualnumber2 = matchstr( getline(lastline), s:C_If0_Txt."\\d\\+" ) + if actualnumber1 != actualnumber2 + echohl WarningMsg | echo 'lines '.frstline.', '.lastline.': comment tags do not match'| echohl None + return + endif + + silent exe ':'.lastline.','.lastline.'d' + silent exe ':'.frstline.','.frstline.'d' + +endfunction " ---------- end of function C_PPIf0Remove ---------- +" +"------------------------------------------------------------------------------- +" C_LegalizeName : replace non-word characters by underscores +" - multiple whitespaces +" - multiple non-word characters +" - multiple underscores +"------------------------------------------------------------------------------- +function! C_LegalizeName ( name ) + let identifier = substitute( a:name, '\s\+', '_', 'g' ) + let identifier = substitute( identifier, '\W\+', '_', 'g' ) + let identifier = substitute( identifier, '_\+', '_', 'g' ) + return identifier +endfunction " ---------- end of function C_LegalizeName ---------- + +"------------------------------------------------------------------------------ +" C_CodeSnippet : read / edit code snippet {{{1 +"------------------------------------------------------------------------------ +function! C_CodeSnippet(mode) + + if isdirectory(s:C_CodeSnippets) + " + " read snippet file, put content below current line and indent + " + if a:mode == "r" + if has("browse") && s:C_GuiSnippetBrowser == 'gui' + let l:snippetfile=browse(0,"read a code snippet",s:C_CodeSnippets,"") + else + let l:snippetfile=input("read snippet ", s:C_CodeSnippets, "file" ) + endif + if filereadable(l:snippetfile) + let linesread= line("$") + let l:old_cpoptions = &cpoptions " Prevent the alternate buffer from being set to this files + setlocal cpoptions-=a + :execute "read ".l:snippetfile + let &cpoptions = l:old_cpoptions " restore previous options + let linesread= line("$")-linesread-1 + if linesread>=0 && match( l:snippetfile, '\.\(ni\|noindent\)$' ) < 0 + endif + endif + if line(".")==2 && getline(1)=~"^$" + silent exe ":1,1d" + endif + endif + " + " update current buffer / split window / edit snippet file + " + if a:mode == "e" + if has("browse") && s:C_GuiSnippetBrowser == 'gui' + let l:snippetfile = browse(0,"edit a code snippet",s:C_CodeSnippets,"") + else + let l:snippetfile=input("edit snippet ", s:C_CodeSnippets, "file" ) + endif + if l:snippetfile != "" + :execute "update! | split | edit ".l:snippetfile + endif + endif + " + " write whole buffer into snippet file + " + if a:mode == "w" || a:mode == "wv" + if has("browse") && s:C_GuiSnippetBrowser == 'gui' + let l:snippetfile = browse(0,"write a code snippet",s:C_CodeSnippets,"") + else + let l:snippetfile=input("write snippet ", s:C_CodeSnippets, "file" ) + endif + if l:snippetfile != "" + if filereadable(l:snippetfile) + if confirm("File ".l:snippetfile." exists ! Overwrite ? ", "&Cancel\n&No\n&Yes") != 3 + return + endif + endif + if a:mode == "w" + :execute ":write! ".l:snippetfile + else + :execute ":*write! ".l:snippetfile + endif + endif + endif + + else + echo "code snippet directory ".s:C_CodeSnippets." does not exist (please create it)" + endif +endfunction " ---------- end of function C_CodeSnippets ---------- +" +"------------------------------------------------------------------------------ +" C_help : builtin completion {{{1 +"------------------------------------------------------------------------------ +function! C_ForTypeComplete ( ArgLead, CmdLine, CursorPos ) + " + " show all types + if a:ArgLead == '' + return s:C_ForTypes + endif + " + " show types beginning with a:ArgLead + let expansions = [] + for item in s:C_ForTypes + if match( item, '\<'.a:ArgLead.'\w*' ) == 0 + call add( expansions, item ) + endif + endfor + return expansions +endfunction " ---------- end of function C_ForTypeComplete ---------- +" +"------------------------------------------------------------------------------ +" C_CodeFor : for (idiom) {{{1 +"------------------------------------------------------------------------------ +function! C_CodeFor( direction, mode ) + " + if a:direction == 'up' + let string = 'INCR.' + else + let string = 'DECR.' + endif + let string = C_Input( '[TYPE (expand)] VARIABLE [START [END ['.string.']]] : ', '', 'customlist,C_ForTypeComplete' ) + if string == '' + return + endif + " + let part = [''] + let nextindex = -1 + for item in s:C_ForTypes + let nextindex = matchend( string, '^'.item ) + if nextindex >= 0 + let part[0] = item + let string = strpart( string, nextindex-1 ) + endif + endfor + let part = part + split( string ) + + if len( part ) > 5 + echohl WarningMsg | echomsg "for loop construction : to many arguments " | echohl None + return + endif + + let missing = 0 + while len(part) < 5 + let part = part + [''] + let missing = missing+1 + endwhile + + let [ loopvar_type, loopvar, startval, endval, incval ] = part + + if incval=='' + let incval = '1' + endif + + if a:direction == 'up' + if endval == '' + let endval = 'n' + endif + if startval == '' + let startval = '0' + endif + let zz= 'for ( '.loopvar_type.loopvar.' = '.startval.'; '.loopvar.' < '.endval.'; '.loopvar.' += '.incval." )" + else + if endval == '' + let endval = '0' + endif + if startval == '' + let startval = 'n-1' + endif + let zz= 'for ( '.loopvar_type.loopvar.' = '.startval.'; '.loopvar.' >= '.endval.'; '.loopvar.' -= '.incval." )" + endif + " + " use internal formatting to avoid conficts when using == below + let equalprg_save = &equalprg + set equalprg= + + " ----- normal mode ---------------- + if a:mode=='a' + let zz = zz." {\n}" + put =zz + normal k + normal 2== + endif + " ----- visual mode ---------------- + if a:mode=='v' + let pos1 = line("'<") + let pos2 = line("'>") + let zz = zz.' {' + let zz2= '}' + exe ":".pos2."put =zz2" + exe ":".pos1."put! =zz" + :exe 'normal ='.(pos2-pos1+2).'+' + endif + " + " restore formatter programm + let &equalprg = equalprg_save + " + " position the cursor + " + normal ^ + if missing == 1 + let match = search( '\<'.incval.'\>', 'W', line(".") ) + else + if missing == 2 + let match = search( '\<'.endval.'\>', 'W', line(".") ) + else + if missing == 3 + let match = search( '\<'.startval.'\>', 'W', line(".") ) + endif + endif + endif + " +endfunction " ---------- end of function C_CodeFor ---------- +" +"------------------------------------------------------------------------------ +" Handle prototypes {{{1 +"------------------------------------------------------------------------------ +" +let s:C_Prototype = [] +let s:C_PrototypeShow = [] +let s:C_PrototypeCounter = 0 +let s:C_CComment = '\/\*.\{-}\*\/\s*' " C comment with trailing whitespaces + " '.\{-}' any character, non-greedy +let s:C_CppComment = '\/\/.*$' " C++ comment +" +"------------------------------------------------------------------------------ +" C_ProtoPick : pick up (normal/visual) {{{1 +"------------------------------------------------------------------------------ +function! C_ProtoPick (mode) + if a:mode=="n" + " --- normal mode ------------------- + let pos1 = line(".") + let pos2 = pos1 + else + " --- visual mode ------------------- + let pos1 = line("'<") + let pos2 = line("'>") + endif + " + " remove C/C++-comments, leading and trailing whitespaces, squeeze whitespaces + " + let prototyp = '' + for linenumber in range( pos1, pos2 ) + let newline = getline(linenumber) + let newline = substitute( newline, s:C_CppComment, "", "" ) " remove C++ comment + let prototyp = prototyp." ".newline + endfor + " + let prototyp = substitute( prototyp, '^\s\+', "", "" ) " remove leading whitespaces + let prototyp = substitute( prototyp, s:C_CComment, "", "g" ) " remove (multiline) C comments + let prototyp = substitute( prototyp, '\s\+', " ", "g" ) " squeeze whitespaces + let prototyp = substitute( prototyp, '\s\+$', "", "" ) " remove trailing whitespaces + " + " remove template keyword + " + let prototyp = substitute( prototyp, '^template\s*<\s*class \w\+\s*>\s*', "", "" ) + " + let parlist = stridx( prototyp, '(' ) " start of the parameter list + let part1 = strpart( prototyp, 0, parlist ) + let part2 = strpart( prototyp, parlist ) + " + " remove the scope res. operator + " + let part1 = substitute( part1, '<\s*\w\+\s*>', "", "g" ) + let part1 = substitute( part1, '\<std\s*::', 'std##', 'g' ) " remove the scope res. operator + let part1 = substitute( part1, '\<\h\w*\s*::', '', 'g' ) " remove the scope res. operator + let part1 = substitute( part1, '\<std##', 'std::', 'g' ) " remove the scope res. operator + let prototyp = part1.part2 + " + " remove trailing parts of the function body; add semicolon + " + let prototyp = substitute( prototyp, '\s*{.*$', "", "" ) + let prototyp = prototyp.";\n" + " + " bookkeeping + " + let s:C_PrototypeCounter += 1 + let s:C_Prototype += [prototyp] + let s:C_PrototypeShow += ["(".s:C_PrototypeCounter.") ".bufname("%")." # ".prototyp] + " + echon s:C_PrototypeCounter.' prototype' + if s:C_PrototypeCounter > 1 + echon 's' + endif + " +endfunction " --------- end of function C_ProtoPick ---------- +" +"------------------------------------------------------------------------------ +" C_ProtoInsert : insert {{{1 +"------------------------------------------------------------------------------ +function! C_ProtoInsert () + " + " use internal formatting to avoid conficts when using == below + let equalprg_save = &equalprg + set equalprg= + " + if s:C_PrototypeCounter > 0 + for protytype in s:C_Prototype + put =protytype + endfor + let lines = s:C_PrototypeCounter - 1 + silent exe "normal =".lines."-" + call C_ProtoClear() + else + echo "currently no prototypes available" + endif + " + " restore formatter programm + let &equalprg = equalprg_save + " +endfunction " --------- end of function C_ProtoInsert ---------- +" +"------------------------------------------------------------------------------ +" C_ProtoClear : clear {{{1 +"------------------------------------------------------------------------------ +function! C_ProtoClear () + if s:C_PrototypeCounter > 0 + let s:C_Prototype = [] + let s:C_PrototypeShow = [] + if s:C_PrototypeCounter == 1 + echo s:C_PrototypeCounter.' prototype deleted' + else + echo s:C_PrototypeCounter.' prototypes deleted' + endif + let s:C_PrototypeCounter = 0 + else + echo "currently no prototypes available" + endif +endfunction " --------- end of function C_ProtoClear ---------- +" +"------------------------------------------------------------------------------ +" C_ProtoShow : show {{{1 +"------------------------------------------------------------------------------ +function! C_ProtoShow () + if s:C_PrototypeCounter > 0 + for protytype in s:C_PrototypeShow + echo protytype + endfor + else + echo "currently no prototypes available" + endif +endfunction " --------- end of function C_ProtoShow ---------- +" +"------------------------------------------------------------------------------ +" C_EscapeBlanks : C_EscapeBlanks {{{1 +"------------------------------------------------------------------------------ +function! C_EscapeBlanks (arg) + return substitute( a:arg, " ", "\\ ", "g" ) +endfunction " --------- end of function C_EscapeBlanks ---------- +" +"------------------------------------------------------------------------------ +" C_Compile : C_Compile {{{1 +"------------------------------------------------------------------------------ +" The standard make program 'make' called by vim is set to the C or C++ compiler +" and reset after the compilation (setlocal makeprg=... ). +" The errorfile created by the compiler will now be read by gvim and +" the commands cl, cp, cn, ... can be used. +"------------------------------------------------------------------------------ +let s:LastShellReturnCode = 0 " for compile / link / run only + +function! C_Compile () + + let s:C_HlMessage = "" + exe ":cclose" + let Sou = expand("%:p") " name of the file in the current buffer + let Obj = expand("%:p:r").s:C_ObjExtension " name of the object + let SouEsc= escape( Sou, s:escfilename ) + let ObjEsc= escape( Obj, s:escfilename ) + + " update : write source file if necessary + exe ":update" + + " compilation if object does not exist or object exists and is older then the source + if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou))) + " &makeprg can be a string containing blanks + let makeprg_saved = '"'.&makeprg.'"' + if expand("%:e") == s:C_CExtension + exe "setlocal makeprg=".s:C_CCompiler + else + exe "setlocal makeprg=".s:C_CplusCompiler + endif + " + " COMPILATION + " + let v:statusmsg = '' + let s:LastShellReturnCode = 0 + if s:MSWIN + exe "make ".s:C_CFlags." \"".SouEsc."\" -o \"".ObjEsc."\"" + else + exe "make ".s:C_CFlags." ".SouEsc." -o ".ObjEsc + endif + exe "setlocal makeprg=".makeprg_saved + if v:statusmsg == '' + let s:C_HlMessage = "'".Obj."' : compilation successful" + endif + if v:shell_error != 0 + let s:LastShellReturnCode = v:shell_error + endif + " + " open error window if necessary + :redraw! + exe ":botright cwindow" + else + let s:C_HlMessage = " '".Obj."' is up to date " + endif + +endfunction " ---------- end of function C_Compile ---------- +" +"------------------------------------------------------------------------------ +" C_Link : C_Link {{{1 +"------------------------------------------------------------------------------ +" The standard make program which is used by gvim is set to the compiler +" (for linking) and reset after linking. +" +" calls: C_Compile +"------------------------------------------------------------------------------ +function! C_Link () + + call C_Compile() + :redraw! + if s:LastShellReturnCode != 0 + let s:LastShellReturnCode = 0 + return + endif + + let s:C_HlMessage = "" + let Sou = expand("%:p") " name of the file (full path) + let Obj = expand("%:p:r").s:C_ObjExtension " name of the object file + let Exe = expand("%:p:r").s:C_ExeExtension " name of the executable + let ObjEsc= escape( Obj, s:escfilename ) + let ExeEsc= escape( Exe, s:escfilename ) + + " no linkage if: + " executable exists + " object exists + " source exists + " executable newer then object + " object newer then source + + if filereadable(Exe) && + \ filereadable(Obj) && + \ filereadable(Sou) && + \ (getftime(Exe) >= getftime(Obj)) && + \ (getftime(Obj) >= getftime(Sou)) + let s:C_HlMessage = " '".Exe."' is up to date " + return + endif + + " linkage if: + " object exists + " source exists + " object newer then source + + if filereadable(Obj) && (getftime(Obj) >= getftime(Sou)) + let makeprg_saved='"'.&makeprg.'"' + if expand("%:e") == s:C_CExtension + exe "setlocal makeprg=".s:C_CCompiler + else + exe "setlocal makeprg=".s:C_CplusCompiler + endif + let s:LastShellReturnCode = 0 + let v:statusmsg = '' + if s:MSWIN + silent exe "make ".s:C_LFlags." ".s:C_Libs." -o \"".ExeEsc."\" \"".ObjEsc."\"" + else + silent exe "make ".s:C_LFlags." ".s:C_Libs." -o ".ExeEsc." ".ObjEsc + endif + if v:statusmsg == '' + let s:C_HlMessage = "'".Exe."' : linking successful" + else + let s:C_HlMessage = "'".Exe."' : linking NOT successful" + endif + if v:shell_error != 0 + let s:LastShellReturnCode = v:shell_error + endif + exe "setlocal makeprg=".makeprg_saved + endif +endfunction " ---------- end of function C_Link ---------- +" +"------------------------------------------------------------------------------ +" C_Run : C_Run {{{1 +" calls: C_Link +"------------------------------------------------------------------------------ +" +let s:C_OutputBufferName = "C-Output" +let s:C_OutputBufferNumber = -1 +let s:C_RunMsg1 ="' does not exist or is not executable or object/source older then executable" +" +function! C_Run () +" + let s:C_HlMessage = "" + let Sou = expand("%:p") " name of the source file + let Obj = expand("%:p:r").s:C_ObjExtension " name of the object file + let Exe = expand("%:p:r").s:C_ExeExtension " name of the executable + let ExeEsc = escape( Exe, s:escfilename ) " name of the executable, escaped + " + let l:arguments = exists("b:C_CmdLineArgs") ? b:C_CmdLineArgs : '' + " + let l:currentbuffer = bufname("%") + " + "============================================================================== + " run : run from the vim command line + "============================================================================== + if s:C_OutputGvim == "vim" + " + silent call C_Link() + if s:LastShellReturnCode == 0 + " clear the last linking message if any" + let s:C_HlMessage = "" + call C_HlMessage() + endif + " + if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou) + if s:MSWIN + exe "!\"".ExeEsc."\" ".l:arguments + else + exe "!".ExeEsc." ".l:arguments + endif + else + echomsg "file '".Exe.s:C_RunMsg1 + endif + + endif + " + "============================================================================== + " run : redirect output to an output buffer + "============================================================================== + if s:C_OutputGvim == "buffer" + let l:currentbuffernr = bufnr("%") + " + silent call C_Link() + " + if l:currentbuffer == bufname("%") + " + " + if bufloaded(s:C_OutputBufferName) != 0 && bufwinnr(s:C_OutputBufferNumber)!=-1 + exe bufwinnr(s:C_OutputBufferNumber) . "wincmd w" + " buffer number may have changed, e.g. after a 'save as' + if bufnr("%") != s:C_OutputBufferNumber + let s:C_OutputBufferNumber = bufnr(s:C_OutputBufferName) + exe ":bn ".s:C_OutputBufferNumber + endif + else + silent exe ":new ".s:C_OutputBufferName + let s:C_OutputBufferNumber=bufnr("%") + setlocal buftype=nofile + setlocal noswapfile + setlocal syntax=none + setlocal bufhidden=delete + setlocal tabstop=8 + endif + " + " run programm + " + setlocal modifiable + if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou) + if s:MSWIN + exe "%!\"".ExeEsc."\" ".l:arguments + else + exe "%!".ExeEsc." ".l:arguments + endif + setlocal nomodifiable + " + if winheight(winnr()) >= line("$") + exe bufwinnr(l:currentbuffernr) . "wincmd w" + endif + else + setlocal nomodifiable + :close + echomsg "file '".Exe.s:C_RunMsg1 + endif + " + endif + endif + " + "============================================================================== + " run : run in a detached xterm (not available for MS Windows) + "============================================================================== + if s:C_OutputGvim == "xterm" + " + silent call C_Link() + " + if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou) + if s:MSWIN + exe "!\"".ExeEsc."\" ".l:arguments + else + silent exe '!xterm -title '.ExeEsc.' '.s:C_XtermDefaults.' -e '.s:C_Wrapper.' '.ExeEsc.' '.l:arguments.' &' + :redraw! + endif + else + echomsg "file '".Exe.s:C_RunMsg1 + endif + endif + + if v:statusmsg == '' + let s:C_HlMessage = "" + endif +endfunction " ---------- end of function C_Run ---------- +" +"------------------------------------------------------------------------------ +" C_Arguments : Arguments for the executable {{{1 +"------------------------------------------------------------------------------ +function! C_Arguments () + let Exe = expand("%:r").s:C_ExeExtension + if Exe == "" + redraw + echohl WarningMsg | echo "no file name " | echohl None + return + endif + let prompt = 'command line arguments for "'.Exe.'" : ' + if exists("b:C_CmdLineArgs") + let b:C_CmdLineArgs= C_Input( prompt, b:C_CmdLineArgs, 'file' ) + else + let b:C_CmdLineArgs= C_Input( prompt , "", 'file' ) + endif +endfunction " ---------- end of function C_Arguments ---------- +" +"---------------------------------------------------------------------- +" C_Toggle_Gvim_Xterm : change output destination {{{1 +"---------------------------------------------------------------------- +function! C_Toggle_Gvim_Xterm () + + if s:C_OutputGvim == "vim" + if has("gui_running") + exe "aunmenu <silent> ".s:Run.'.&output:\ VIM->buffer->xterm' + exe "amenu <silent> ".s:Run.'.&output:\ BUFFER->xterm->vim :call C_Toggle_Gvim_Xterm()<CR><CR>' + exe "imenu <silent> ".s:Run.'.&output:\ BUFFER->xterm->vim <C-C>:call C_Toggle_Gvim_Xterm()<CR><CR>' + endif + let s:C_OutputGvim = "buffer" + else + if s:C_OutputGvim == "buffer" + if has("gui_running") + exe "aunmenu <silent> ".s:Run.'.&output:\ BUFFER->xterm->vim' + if (!s:MSWIN) + exe "amenu <silent> ".s:Run.'.&output:\ XTERM->vim->buffer :call C_Toggle_Gvim_Xterm()<CR><CR>' + exe "imenu <silent> ".s:Run.'.&output:\ XTERM->vim->buffer <C-C>:call C_Toggle_Gvim_Xterm()<CR><CR>' + else + exe "amenu <silent> ".s:Run.'.&output:\ VIM->buffer->xterm :call C_Toggle_Gvim_Xterm()<CR><CR>' + exe "imenu <silent> ".s:Run.'.&output:\ VIM->buffer->xterm <C-C>:call C_Toggle_Gvim_Xterm()<CR><CR>' + endif + endif + if (!s:MSWIN) && (s:C_Display != '') + let s:C_OutputGvim = "xterm" + else + let s:C_OutputGvim = "vim" + endif + else + " ---------- output : xterm -> gvim + if has("gui_running") + exe "aunmenu <silent> ".s:Run.'.&output:\ XTERM->vim->buffer' + exe "amenu <silent> ".s:Run.'.&output:\ VIM->buffer->xterm :call C_Toggle_Gvim_Xterm()<CR><CR>' + exe "imenu <silent> ".s:Run.'.&output:\ VIM->buffer->xterm <C-C>:call C_Toggle_Gvim_Xterm()<CR><CR>' + endif + let s:C_OutputGvim = "vim" + endif + endif + echomsg "output destination is '".s:C_OutputGvim."'" + +endfunction " ---------- end of function C_Toggle_Gvim_Xterm ---------- +" +"------------------------------------------------------------------------------ +" C_XtermSize : xterm geometry {{{1 +"------------------------------------------------------------------------------ +function! C_XtermSize () + let regex = '-geometry\s\+\d\+x\d\+' + let geom = matchstr( s:C_XtermDefaults, regex ) + let geom = matchstr( geom, '\d\+x\d\+' ) + let geom = substitute( geom, 'x', ' ', "" ) + let answer= C_Input(" xterm size (COLUMNS LINES) : ", geom ) + while match(answer, '^\s*\d\+\s\+\d\+\s*$' ) < 0 + let answer= C_Input(" + xterm size (COLUMNS LINES) : ", geom ) + endwhile + let answer = substitute( answer, '\s\+', "x", "" ) " replace inner whitespaces + let s:C_XtermDefaults = substitute( s:C_XtermDefaults, regex, "-geometry ".answer , "" ) +endfunction " ---------- end of function C_XtermSize ---------- +" +"------------------------------------------------------------------------------ +" C_MakeArguments : run make(1) {{{1 +"------------------------------------------------------------------------------ + +let s:C_MakeCmdLineArgs = "" " command line arguments for Run-make; initially empty + +function! C_MakeArguments () + let s:C_MakeCmdLineArgs= C_Input("make command line arguments : ",s:C_MakeCmdLineArgs ) +endfunction " ---------- end of function C_MakeArguments ---------- +" +function! C_Make() + " update : write source file if necessary + exe ":update" + " run make + exe ":!make ".s:C_MakeCmdLineArgs +endfunction " ---------- end of function C_Make ---------- +" +"------------------------------------------------------------------------------ +" C_SplintArguments : splint command line arguments {{{1 +"------------------------------------------------------------------------------ +function! C_SplintArguments () + if s:C_SplintIsExecutable==0 + let s:C_HlMessage = ' Splint is not executable or not installed! ' + else + let prompt = 'Splint command line arguments for "'.expand("%").'" : ' + if exists("b:C_SplintCmdLineArgs") + let b:C_SplintCmdLineArgs= C_Input( prompt, b:C_SplintCmdLineArgs ) + else + let b:C_SplintCmdLineArgs= C_Input( prompt , "" ) + endif + endif +endfunction " ---------- end of function C_SplintArguments ---------- +" +"------------------------------------------------------------------------------ +" C_SplintCheck : run splint(1) {{{1 +"------------------------------------------------------------------------------ +function! C_SplintCheck () + if s:C_SplintIsExecutable==0 + let s:C_HlMessage = ' Splint is not executable or not installed! ' + return + endif + let l:currentbuffer=bufname("%") + if &filetype != "c" && &filetype != "cpp" + let s:C_HlMessage = ' "'.l:currentbuffer.'" seems not to be a C/C++ file ' + return + endif + let s:C_HlMessage = "" + exe ":cclose" + silent exe ":update" + let makeprg_saved='"'.&makeprg.'"' + " Windows seems to need this: + if s:MSWIN + :compiler splint + endif + :setlocal makeprg=splint + " + let l:arguments = exists("b:C_SplintCmdLineArgs") ? b:C_SplintCmdLineArgs : ' ' + silent exe "make ".l:arguments." ".escape(l:currentbuffer,s:escfilename) + exe "setlocal makeprg=".makeprg_saved + exe ":botright cwindow" + " + " message in case of success + " + if l:currentbuffer == bufname("%") + let s:C_HlMessage = " Splint --- no warnings for : ".l:currentbuffer + endif +endfunction " ---------- end of function C_SplintCheck ---------- +" +"------------------------------------------------------------------------------ +" C_CodeCheckArguments : CodeCheck command line arguments {{{1 +"------------------------------------------------------------------------------ +function! C_CodeCheckArguments () + if s:C_CodeCheckIsExecutable==0 + let s:C_HlMessage = ' CodeCheck is not executable or not installed! ' + else + let prompt = 'CodeCheck command line arguments for "'.expand("%").'" : ' + if exists("b:C_CodeCheckCmdLineArgs") + let b:C_CodeCheckCmdLineArgs= C_Input( prompt, b:C_CodeCheckCmdLineArgs ) + else + let b:C_CodeCheckCmdLineArgs= C_Input( prompt , s:C_CodeCheckOptions ) + endif + endif +endfunction " ---------- end of function C_CodeCheckArguments ---------- +" +"------------------------------------------------------------------------------ +" C_CodeCheck : run CodeCheck {{{1 +"------------------------------------------------------------------------------ +function! C_CodeCheck () + if s:C_CodeCheckIsExecutable==0 + let s:C_HlMessage = ' CodeCheck is not executable or not installed! ' + return + endif + let l:currentbuffer=bufname("%") + if &filetype != "c" && &filetype != "cpp" + let s:C_HlMessage = ' "'.l:currentbuffer.'" seems not to be a C/C++ file ' + return + endif + let s:C_HlMessage = "" + exe ":cclose" + silent exe ":update" + let makeprg_saved='"'.&makeprg.'"' + exe "setlocal makeprg=".s:C_CodeCheckExeName + " + " match the splint error messages (quickfix commands) + " ignore any lines that didn't match one of the patterns + " + :setlocal errorformat=%f(%l)%m + " + let l:arguments = exists("b:C_CodeCheckCmdLineArgs") ? b:C_CodeCheckCmdLineArgs : "" + if l:arguments == "" + let l:arguments = s:C_CodeCheckOptions + endif + exe ":make ".l:arguments." ".escape( l:currentbuffer, s:escfilename ) + exe ':setlocal errorformat=' + exe ":setlocal makeprg=".makeprg_saved + exe ":botright cwindow" + " + " message in case of success + " + if l:currentbuffer == bufname("%") + let s:C_HlMessage = " CodeCheck --- no warnings for : ".l:currentbuffer + endif +endfunction " ---------- end of function C_CodeCheck ---------- +" +"------------------------------------------------------------------------------ +" C_Indent : run indent(1) {{{1 +"------------------------------------------------------------------------------ +" +function! C_Indent ( ) + if !executable("indent") + echomsg 'indent is not executable or not installed!' + return + endif + let l:currentbuffer=expand("%:p") + if &filetype != "c" && &filetype != "cpp" + echomsg '"'.l:currentbuffer.'" seems not to be a C/C++ file ' + return + endif + if C_Input("indent whole file [y/n/Esc] : ", "y" ) != "y" + return + endif + :update + + exe ":cclose" + if s:MSWIN + silent exe ":%!indent " + else + silent exe ":%!indent 2> ".s:C_IndentErrorLog + redraw! + if getfsize( s:C_IndentErrorLog ) > 0 + exe ':edit! '.s:C_IndentErrorLog + let errorlogbuffer = bufnr("%") + exe ':%s/^indent: Standard input/indent: '.escape( l:currentbuffer, '/' ).'/' + setlocal errorformat=indent:\ %f:%l:%m + :cbuffer + exe ':bdelete! '.errorlogbuffer + exe ':botright cwindow' + else + echomsg 'File "'.l:currentbuffer.'" reformatted.' + endif + setlocal errorformat= + endif + +endfunction " ---------- end of function C_Indent ---------- +" +"------------------------------------------------------------------------------ +" C_HlMessage : indent message {{{1 +"------------------------------------------------------------------------------ +function! C_HlMessage () + redraw! + echohl Search + echo s:C_HlMessage + echohl None +endfunction " ---------- end of function C_HlMessage ---------- +" +"------------------------------------------------------------------------------ +" C_Settings : settings {{{1 +"------------------------------------------------------------------------------ +function! C_Settings () + let txt = " C/C++-Support settings\n\n" + let txt = txt.' author : "'.s:C_Macro['|AUTHOR|']."\"\n" + let txt = txt.' initials : "'.s:C_Macro['|AUTHORREF|']."\"\n" + let txt = txt.' email : "'.s:C_Macro['|EMAIL|']."\"\n" + let txt = txt.' company : "'.s:C_Macro['|COMPANY|']."\"\n" + let txt = txt.' project : "'.s:C_Macro['|PROJECT|']."\"\n" + let txt = txt.' copyright holder : "'.s:C_Macro['|COPYRIGHTHOLDER|']."\"\n" + let txt = txt.' C / C++ compiler : '.s:C_CCompiler.' / '.s:C_CplusCompiler."\n" + let txt = txt.' C file extension : "'.s:C_CExtension.'" (everything else is C++)'."\n" + let txt = txt.' extension for objects : "'.s:C_ObjExtension."\"\n" + let txt = txt.'extension for executables : "'.s:C_ExeExtension."\"\n" + let txt = txt.' compiler flags : "'.s:C_CFlags."\"\n" + let txt = txt.' linker flags : "'.s:C_LFlags."\"\n" + let txt = txt.' libraries : "'.s:C_Libs."\"\n" + let txt = txt.' code snippet directory : "'.s:C_CodeSnippets."\"\n" + " ----- template files ------------------------ + let txt = txt.' template style : "'.s:C_ActualStyle."\"\n" + if s:installation == 'system' + let txt = txt.'global template directory : '.s:C_GlobalTemplateDir."\n" + if filereadable( s:C_LocalTemplateFile ) + let txt = txt.' local template directory : '.s:C_LocalTemplateDir."\n" + endif + else + let txt = txt.' local template directory : '.s:C_GlobalTemplateDir."\n" + endif + if !s:MSWIN + let txt = txt.' xterm defaults : '.s:C_XtermDefaults."\n" + endif + " ----- dictionaries ------------------------ + if g:C_Dictionary_File != "" + let ausgabe= &dictionary + let ausgabe= substitute( ausgabe, ",", ",\n + ", "g" ) + let txt = txt." dictionary file(s) : ".ausgabe."\n" + endif + let txt = txt.' current output dest. : '.s:C_OutputGvim."\n" + " ----- splint ------------------------------ + if s:C_SplintIsExecutable==1 + if exists("b:C_SplintCmdLineArgs") + let ausgabe = b:C_SplintCmdLineArgs + else + let ausgabe = "" + endif + let txt = txt." splint options(s) : ".ausgabe."\n" + endif + " ----- code check -------------------------- + if s:C_CodeCheckIsExecutable==1 + if exists("b:C_CodeCheckCmdLineArgs") + let ausgabe = b:C_CodeCheckCmdLineArgs + else + let ausgabe = s:C_CodeCheckOptions + endif + let txt = txt."CodeCheck (TM) options(s) : ".ausgabe."\n" + endif + let txt = txt."\n" + let txt = txt."__________________________________________________________________________\n" + let txt = txt." C/C++-Support, Version ".g:C_Version." / Dr.-Ing. Fritz Mehner / mehner@fh-swf.de\n\n" + echo txt +endfunction " ---------- end of function C_Settings ---------- +" +"------------------------------------------------------------------------------ +" C_Hardcopy : hardcopy {{{1 +" MSWIN : a printer dialog is displayed +" other : print PostScript to file +"------------------------------------------------------------------------------ +function! C_Hardcopy (mode) + let outfile = expand("%") + if outfile == "" + let s:C_HlMessage = 'Buffer has no name.' + call C_HlMessage() + endif + let outdir = getcwd() + if filewritable(outdir) != 2 + let outdir = $HOME + endif + if !s:MSWIN + let outdir = outdir.'/' + endif + let old_printheader=&printheader + exe ':set printheader='.s:C_Printheader + " ----- normal mode ---------------- + if a:mode=="n" + silent exe 'hardcopy > '.outdir.outfile.'.ps' + if !s:MSWIN + echo 'file "'.outfile.'" printed to "'.outdir.outfile.'.ps"' + endif + endif + " ----- visual mode ---------------- + if a:mode=="v" + silent exe "*hardcopy > ".outdir.outfile.".ps" + if !s:MSWIN + echo 'file "'.outfile.'" (lines '.line("'<").'-'.line("'>").') printed to "'.outdir.outfile.'.ps"' + endif + endif + exe ':set printheader='.escape( old_printheader, ' %' ) +endfunction " ---------- end of function C_Hardcopy ---------- +" +"------------------------------------------------------------------------------ +" C_HelpCsupport : help csupport {{{1 +"------------------------------------------------------------------------------ +function! C_HelpCsupport () + try + :help csupport + catch + exe ':helptags '.s:plugin_dir.'doc' + :help csupport + endtry +endfunction " ---------- end of function C_HelpCsupport ---------- +" +"------------------------------------------------------------------------------ +" C_Help : lookup word under the cursor or ask {{{1 +"------------------------------------------------------------------------------ +" +let s:C_DocBufferName = "C_HELP" +let s:C_DocHelpBufferNumber = -1 +" +function! C_Help( type ) + + let cuc = getline(".")[col(".") - 1] " character under the cursor + let item = expand("<cword>") " word under the cursor + if cuc == '' || item == "" || match( item, cuc ) == -1 + let item=C_Input('name of the manual page : ', '' ) + endif + + if item == "" + return + endif + "------------------------------------------------------------------------------ + " replace buffer content with bash help text + "------------------------------------------------------------------------------ + " + " jump to an already open bash help window or create one + " + if bufloaded(s:C_DocBufferName) != 0 && bufwinnr(s:C_DocHelpBufferNumber) != -1 + exe bufwinnr(s:C_DocHelpBufferNumber) . "wincmd w" + " buffer number may have changed, e.g. after a 'save as' + if bufnr("%") != s:C_DocHelpBufferNumber + let s:C_DocHelpBufferNumber=bufnr(s:C_OutputBufferName) + exe ":bn ".s:C_DocHelpBufferNumber + endif + else + exe ":new ".s:C_DocBufferName + let s:C_DocHelpBufferNumber=bufnr("%") + setlocal buftype=nofile + setlocal noswapfile + setlocal bufhidden=delete + setlocal filetype=sh " allows repeated use of <S-F1> + setlocal syntax=OFF + endif + setlocal modifiable + " + if a:type == 'm' + " + " Is there more than one manual ? + " + let manpages = system( s:C_Man.' -k '.item ) + if v:shell_error + echomsg "Shell command '".s:C_Man." -k ".item."' failed." + :close + return + endif + let catalogs = split( manpages, '\n', ) + let manual = {} + " + " Select manuals where the name exactly matches + " + for line in catalogs + if line =~ '^'.item.'\s\+(' + let itempart = split( line, '\s\+' ) + let catalog = itempart[1][1:-2] + if match( catalog, '.p$' ) == -1 + let manual[catalog] = catalog + endif + endif + endfor + " + " Build a selection list if there are more than one manual + " + let catalog = "" + if len(keys(manual)) > 1 + for key in keys(manual) + echo ' '.item.' '.key + endfor + let defaultcatalog = '' + if has_key( manual, '3' ) + let defaultcatalog = '3' + else + if has_key( manual, '2' ) + let defaultcatalog = '2' + endif + endif + let catalog = input( 'select manual section (<Enter> cancels) : ', defaultcatalog ) + if ! has_key( manual, catalog ) + :close + :redraw + echomsg "no appropriate manual section '".catalog."'" + return + endif + endif + + set filetype=man + silent exe ":%!".s:C_Man." ".catalog." ".item + + endif + + setlocal nomodifiable +endfunction " ---------- end of function C_Help ---------- + +"------------------------------------------------------------------------------ +" C_CreateGuiMenus {{{1 +"------------------------------------------------------------------------------ +let s:C_MenuVisible = 0 " state variable controlling the C-menus +" +function! C_CreateGuiMenus () + if s:C_MenuVisible != 1 + aunmenu <silent> &Tools.Load\ C\ Support + amenu <silent> 40.1000 &Tools.-SEP100- : + amenu <silent> 40.1030 &Tools.Unload\ C\ Support <C-C>:call C_RemoveGuiMenus()<CR> + call C_InitMenus() + let s:C_MenuVisible = 1 + endif +endfunction " ---------- end of function C_CreateGuiMenus ---------- + +"------------------------------------------------------------------------------ +" C_ToolMenu {{{1 +"------------------------------------------------------------------------------ +function! C_ToolMenu () + amenu <silent> 40.1000 &Tools.-SEP100- : + amenu <silent> 40.1030 &Tools.Load\ C\ Support :call C_CreateGuiMenus()<CR> + imenu <silent> 40.1030 &Tools.Load\ C\ Support <C-C>:call C_CreateGuiMenus()<CR> +endfunction " ---------- end of function C_ToolMenu ---------- + +"------------------------------------------------------------------------------ +" C_RemoveGuiMenus {{{1 +"------------------------------------------------------------------------------ +function! C_RemoveGuiMenus () + if s:C_MenuVisible == 1 + if s:C_Root == "" + aunmenu <silent> Comments + aunmenu <silent> Statements + aunmenu <silent> Preprocessor + aunmenu <silent> Idioms + aunmenu <silent> Snippets + aunmenu <silent> C++ + aunmenu <silent> Run + else + exe "aunmenu <silent> ".s:C_Root + endif + " + aunmenu <silent> &Tools.Unload\ C\ Support + call C_ToolMenu() + " + let s:C_MenuVisible = 0 + endif +endfunction " ---------- end of function C_RemoveGuiMenus ---------- + +"------------------------------------------------------------------------------ +" C_RereadTemplates {{{1 +" rebuild commands and the menu from the (changed) template file +"------------------------------------------------------------------------------ +function! C_RereadTemplates () + let s:style = 'default' + let s:C_Template = { 'default' : {} } + let s:C_FileVisited = [] + call C_ReadTemplates(s:C_GlobalTemplateFile) + echomsg "templates rebuilt from '".s:C_GlobalTemplateFile."'" + " + if s:installation == 'system' && filereadable( s:C_LocalTemplateFile ) + call C_ReadTemplates( s:C_LocalTemplateFile ) + echomsg " and from '".s:C_LocalTemplateFile."'" + endif +endfunction " ---------- end of function C_RereadTemplates ---------- + +"------------------------------------------------------------------------------ +" C_BrowseTemplateFiles {{{1 +"------------------------------------------------------------------------------ +function! C_BrowseTemplateFiles ( type ) + if filereadable( eval( 's:C_'.a:type.'TemplateFile' ) ) + if has("browse") && s:C_GuiTemplateBrowser == 'gui' + let l:templatefile = browse(0,"edit a template file", eval('s:C_'.a:type.'TemplateDir'), "" ) + else + let l:templatefile = '' + if s:C_GuiTemplateBrowser == 'explorer' + exe ':Explore '.eval('s:C_'.a:type.'TemplateDir') + endif + if s:C_GuiTemplateBrowser == 'commandline' + let l:templatefile = input("edit a template file", eval('s:C_'.a:type.'TemplateDir'), "file" ) + endif + endif + if l:templatefile != "" + :execute "update! | split | edit ".l:templatefile + endif + else + echomsg a:type." template file not readable." + endif +endfunction " ---------- end of function C_BrowseTemplateFiles ---------- + +"------------------------------------------------------------------------------ +" C_EditTemplates {{{1 +"------------------------------------------------------------------------------ +function! C_EditTemplates ( type ) + " + if a:type == 'global' + if s:installation == 'system' + call C_BrowseTemplateFiles('Global') + else + echomsg "C/C++-Support is user installed: no global template file" + endif + endif + " + if a:type == 'local' + if s:installation == 'system' + call C_BrowseTemplateFiles('Local') + else + call C_BrowseTemplateFiles('Global') + endif + endif + " +endfunction " ---------- end of function C_EditTemplates ---------- +" +"------------------------------------------------------------------------------ +" C_ReadTemplates {{{1 +" read the template file(s), build the macro and the template dictionary +" +"------------------------------------------------------------------------------ +let s:style = 'default' +function! C_ReadTemplates ( templatefile ) + + if !filereadable( a:templatefile ) + echohl WarningMsg + echomsg "C/C++ template file '".a:templatefile."' does not exist or is not readable" + echohl None + return + endif + + let skipmacros = 0 + let s:C_FileVisited += [a:templatefile] + + "------------------------------------------------------------------------------ + " read template file, start with an empty template dictionary + "------------------------------------------------------------------------------ + + let item = '' + let skipline = 0 + for line in readfile( a:templatefile ) + " if not a comment : + if line !~ s:C_MacroCommentRegex + " + "------------------------------------------------------------------------------- + " IF |STYLE| IS ... + "------------------------------------------------------------------------------- + " + let string = matchlist( line, s:C_TemplateIf ) + if !empty(string) + if !has_key( s:C_Template, string[1] ) + " new s:style + let s:style = string[1] + let s:C_Template[s:style] = {} + continue + endif + endif + " + "------------------------------------------------------------------------------- + " ENDIF + "------------------------------------------------------------------------------- + " + let string = matchlist( line, s:C_TemplateEndif ) + if !empty(string) + let s:style = 'default' + continue + endif + " + " macros and file includes + " + let string = matchlist( line, s:C_MacroLineRegex ) + if !empty(string) && skipmacros == 0 + let key = '|'.string[1].'|' + let val = string[2] + let val = substitute( val, '\s\+$', '', '' ) + let val = substitute( val, "[\"\']$", '', '' ) + let val = substitute( val, "^[\"\']", '', '' ) + " + if key == '|includefile|' && count( s:C_FileVisited, val ) == 0 + let path = fnamemodify( a:templatefile, ":p:h" ) + call C_ReadTemplates( path.'/'.val ) " recursive call + else + let s:C_Macro[key] = escape( val, '&' ) + endif + continue " next line + endif + " + " template header + " + let name = matchstr( line, s:C_TemplateLineRegex ) + " + if name != '' + let part = split( name, '\s*==\s*') + let item = part[0] + if has_key( s:C_Template[s:style], item ) && s:C_TemplateOverwrittenMsg == 'yes' + echomsg "existing C/C++ template '".item."' overwritten" + endif + let s:C_Template[s:style][item] = '' + let skipmacros = 1 + " + let s:C_Attribute[item] = 'below' + if has_key( s:Attribute, get( part, 1, 'NONE' ) ) + let s:C_Attribute[item] = part[1] + endif + else + if item != '' + let s:C_Template[s:style][item] .= line."\n" + endif + endif + endif + " + endfor " --------- read line --------- + + let s:C_ActualStyle = 'default' + if s:C_Macro['|STYLE|'] != '' + let s:C_ActualStyle = s:C_Macro['|STYLE|'] + endif + let s:C_ActualStyleLast = s:C_ActualStyle + + call C_SetSmallCommentStyle() +endfunction " ---------- end of function C_ReadTemplates ---------- + +"------------------------------------------------------------------------------ +" C_Style{{{1 +" ex-command CStyle : callback function +"------------------------------------------------------------------------------ +function! C_Style ( style ) + let lstyle = substitute( a:style, '^\s\+', "", "" ) " remove leading whitespaces + let lstyle = substitute( lstyle, '\s\+$', "", "" ) " remove trailing whitespaces + if has_key( s:C_Template, lstyle ) + if len( s:C_Template[lstyle] ) == 0 + echomsg "style '".lstyle."' : no templates defined" + return + endif + let s:C_ActualStyleLast = s:C_ActualStyle + let s:C_ActualStyle = lstyle + if len( s:C_ActualStyle ) > 1 && s:C_ActualStyle != s:C_ActualStyleLast + echomsg "template style is '".lstyle."'" + endif + else + echomsg "style '".lstyle."' does not exist" + endif +endfunction " ---------- end of function C_Style ---------- + +"------------------------------------------------------------------------------ +" C_StyleList {{{1 +" ex-command CStyle +"------------------------------------------------------------------------------ +function! C_StyleList ( ArgLead, CmdLine, CursorPos ) + " show all types / types beginning with a:ArgLead + return filter( copy(keys( s:C_Template) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) +endfunction " ---------- end of function C_StyleList ---------- + +"------------------------------------------------------------------------------ +" C_OpenFold {{{1 +" Open fold and go to the first or last line of this fold. +"------------------------------------------------------------------------------ +function! C_OpenFold ( mode ) + if foldclosed(".") >= 0 + " we are on a closed fold: get end position, open fold, jump to the + " last line of the previously closed fold + let foldstart = foldclosed(".") + let foldend = foldclosedend(".") + normal zv + if a:mode == 'below' + exe ":".foldend + endif + if a:mode == 'start' + exe ":".foldstart + endif + endif +endfunction " ---------- end of function C_OpenFold ---------- + +"------------------------------------------------------------------------------ +" C_InsertTemplate {{{1 +" insert a template from the template dictionary +" do macro expansion +"------------------------------------------------------------------------------ +function! C_InsertTemplate ( key, ... ) + + if !has_key( s:C_Template[s:C_ActualStyle], a:key ) && + \ !has_key( s:C_Template['default'], a:key ) + echomsg "style '".a:key."' / template '".a:key + \ ."' not found. Please check your template file in '".s:C_GlobalTemplateDir."'" + return + endif + + if &foldenable + let foldmethod_save = &foldmethod + set foldmethod=manual + endif + "------------------------------------------------------------------------------ + " insert the user macros + "------------------------------------------------------------------------------ + + " use internal formatting to avoid conficts when using == below + " + let equalprg_save = &equalprg + set equalprg= + + let mode = s:C_Attribute[a:key] + + " remove <SPLIT> and insert the complete macro + " + if a:0 == 0 + let val = C_ExpandUserMacros (a:key) + if val == "" + return + endif + let val = C_ExpandSingleMacro( val, '<SPLIT>', '' ) + + if mode == 'below' + call C_OpenFold('below') + let pos1 = line(".")+1 + put =val + let pos2 = line(".") + " proper indenting + exe ":".pos1 + let ins = pos2-pos1+1 + exe "normal ".ins."==" + " + elseif mode == 'above' + let pos1 = line(".") + put! =val + let pos2 = line(".") + " proper indenting + exe ":".pos1 + let ins = pos2-pos1+1 + exe "normal ".ins."==" + " + elseif mode == 'start' + normal gg + call C_OpenFold('start') + let pos1 = 1 + put! =val + let pos2 = line(".") + " proper indenting + exe ":".pos1 + let ins = pos2-pos1+1 + exe "normal ".ins."==" + " + elseif mode == 'append' + if &foldenable && foldclosed(".") >= 0 + echohl WarningMsg | echomsg s:MsgInsNotAvail | echohl None + exe "set foldmethod=".foldmethod_save + return + else + let pos1 = line(".") + put =val + let pos2 = line(".")-1 + exe ":".pos1 + :join! + endif + " + elseif mode == 'insert' + if &foldenable && foldclosed(".") >= 0 + echohl WarningMsg | echomsg s:MsgInsNotAvail | echohl None + exe "set foldmethod=".foldmethod_save + return + else + let val = substitute( val, '\n$', '', '' ) + let currentline = getline( "." ) + let pos1 = line(".") + let pos2 = pos1 + count( split(val,'\zs'), "\n" ) + " assign to the unnamed register "" : + let @"=val + normal p + " reformat only multiline inserts and previously empty lines + if pos2-pos1 > 0 || currentline =~ '' + exe ":".pos1 + let ins = pos2-pos1+1 + exe "normal ".ins."==" + endif + endif + " + endif + " + else + " + " ===== visual mode =============================== + " + if a:1 == 'v' + let val = C_ExpandUserMacros (a:key) + let val = C_ExpandSingleMacro( val, s:C_TemplateJumpTarget2, '' ) + if val == "" + return + endif + + if match( val, '<SPLIT>\s*\n' ) >= 0 + let part = split( val, '<SPLIT>\s*\n' ) + else + let part = split( val, '<SPLIT>' ) + endif + + if len(part) < 2 + let part = [ "" ] + part + echomsg 'SPLIT missing in template '.a:key + endif + " + " 'visual' and mode 'insert': + " <part0><marked area><part1> + " part0 and part1 can consist of several lines + " + if mode == 'insert' + let pos1 = line(".") + let pos2 = pos1 + let string= @* + let replacement = part[0].string.part[1] + " remove trailing '\n' + let replacement = substitute( replacement, '\n$', '', '' ) + exe ':s/'.string.'/'.replacement.'/' + endif + " + " 'visual' and mode 'below': + " <part0> + " <marked area> + " <part1> + " part0 and part1 can consist of several lines + " + if mode == 'below' + + :'<put! =part[0] + :'>put =part[1] + + let pos1 = line("'<") - len(split(part[0], '\n' )) + let pos2 = line("'>") + len(split(part[1], '\n' )) + "" echo part[0] part[1] pos1 pos2 + " " proper indenting + exe ":".pos1 + let ins = pos2-pos1+1 + exe "normal ".ins."==" + endif + " + endif " ---------- end visual mode + endif + + " restore formatter programm + let &equalprg = equalprg_save + + "------------------------------------------------------------------------------ + " position the cursor + "------------------------------------------------------------------------------ + exe ":".pos1 + let mtch = search( '<CURSOR>', 'c', pos2 ) + if mtch != 0 + let line = getline(mtch) + if line =~ '<CURSOR>$' + call setline( mtch, substitute( line, '<CURSOR>', '', '' ) ) + if a:0 != 0 && a:1 == 'v' && getline(".") =~ '^\s*$' + normal J + else + :startinsert! + endif + else + call setline( mtch, substitute( line, '<CURSOR>', '', '' ) ) + :startinsert + endif + else + " to the end of the block; needed for repeated inserts + if mode == 'below' + exe ":".pos2 + endif + endif + + "------------------------------------------------------------------------------ + " marked words + "------------------------------------------------------------------------------ + " define a pattern to highlight + call C_HighlightJumpTargets () + + if &foldenable + " restore folding method + exe "set foldmethod=".foldmethod_save + normal zv + endif + +endfunction " ---------- end of function C_InsertTemplate ---------- + +"------------------------------------------------------------------------------ +" C_HighlightJumpTargets +"------------------------------------------------------------------------------ +function! C_HighlightJumpTargets () + if s:C_Ctrl_j == 'on' + exe 'match Search /'.s:C_TemplateJumpTarget1.'\|'.s:C_TemplateJumpTarget2.'/' + endif +endfunction " ---------- end of function C_HighlightJumpTargets ---------- + +"------------------------------------------------------------------------------ +" C_JumpCtrlJ {{{1 +"------------------------------------------------------------------------------ +function! C_JumpCtrlJ () + let match = search( s:C_TemplateJumpTarget1.'\|'.s:C_TemplateJumpTarget2, 'c' ) + if match > 0 + " remove the target + call setline( match, substitute( getline('.'), s:C_TemplateJumpTarget1.'\|'.s:C_TemplateJumpTarget2, '', '' ) ) + else + " try to jump behind parenthesis or strings in the current line + if match( getline(".")[col(".") - 1], "[\]})\"'`]" ) != 0 + call search( "[\]})\"'`]", '', line(".") ) + endif + normal l + endif + return '' +endfunction " ---------- end of function C_JumpCtrlJ ---------- + +"------------------------------------------------------------------------------ +" C_ExpandUserMacros {{{1 +"------------------------------------------------------------------------------ +function! C_ExpandUserMacros ( key ) + + if has_key( s:C_Template[s:C_ActualStyle], a:key ) + let template = s:C_Template[s:C_ActualStyle][ a:key ] + else + let template = s:C_Template['default'][ a:key ] + endif + let s:C_ExpansionCounter = {} " reset the expansion counter + + "------------------------------------------------------------------------------ + " renew the predefined macros and expand them + " can be replaced, with e.g. |?DATE| + "------------------------------------------------------------------------------ + let s:C_Macro['|BASENAME|'] = toupper(expand("%:t:r")) + let s:C_Macro['|DATE|'] = C_DateAndTime('d') + let s:C_Macro['|FILENAME|'] = expand("%:t") + let s:C_Macro['|PATH|'] = expand("%:p:h") + let s:C_Macro['|SUFFIX|'] = expand("%:e") + let s:C_Macro['|TIME|'] = C_DateAndTime('t') + let s:C_Macro['|YEAR|'] = C_DateAndTime('y') + + "------------------------------------------------------------------------------ + " delete jump targets if mapping for C-j is off + "------------------------------------------------------------------------------ + if s:C_Ctrl_j == 'off' + let template = substitute( template, s:C_TemplateJumpTarget1.'\|'.s:C_TemplateJumpTarget2, '', 'g' ) + endif + + "------------------------------------------------------------------------------ + " look for replacements + "------------------------------------------------------------------------------ + while match( template, s:C_ExpansionRegex ) != -1 + let macro = matchstr( template, s:C_ExpansionRegex ) + let replacement = substitute( macro, '?', '', '' ) + let template = substitute( template, macro, replacement, "g" ) + + let match = matchlist( macro, s:C_ExpansionRegex ) + + if match[1] != '' + let macroname = '|'.match[1].'|' + " + " notify flag action, if any + let flagaction = '' + if has_key( s:C_MacroFlag, match[2] ) + let flagaction = ' (-> '.s:C_MacroFlag[ match[2] ].')' + endif + " + " ask for a replacement + if has_key( s:C_Macro, macroname ) + let name = C_Input( match[1].flagaction.' : ', C_ApplyFlag( s:C_Macro[macroname], match[2] ) ) + else + let name = C_Input( match[1].flagaction.' : ', '' ) + endif + if name == "" + return "" + endif + " + " keep the modified name + let s:C_Macro[macroname] = C_ApplyFlag( name, match[2] ) + endif + endwhile + + "------------------------------------------------------------------------------ + " do the actual macro expansion + " loop over the macros found in the template + "------------------------------------------------------------------------------ + while match( template, s:C_NonExpansionRegex ) != -1 + + let macro = matchstr( template, s:C_NonExpansionRegex ) + let match = matchlist( macro, s:C_NonExpansionRegex ) + + if match[1] != '' + let macroname = '|'.match[1].'|' + + if has_key( s:C_Macro, macroname ) + "------------------------------------------------------------------------------- + " check for recursion + "------------------------------------------------------------------------------- + if has_key( s:C_ExpansionCounter, macroname ) + let s:C_ExpansionCounter[macroname] += 1 + else + let s:C_ExpansionCounter[macroname] = 0 + endif + if s:C_ExpansionCounter[macroname] >= s:C_ExpansionLimit + echomsg " recursion terminated for recursive macro ".macroname + return template + endif + "------------------------------------------------------------------------------- + " replace + "------------------------------------------------------------------------------- + let replacement = C_ApplyFlag( s:C_Macro[macroname], match[2] ) + let template = substitute( template, macro, replacement, "g" ) + else + " + " macro not yet defined + let s:C_Macro['|'.match[1].'|'] = '' + endif + endif + + endwhile + + return template +endfunction " ---------- end of function C_ExpandUserMacros ---------- + +"------------------------------------------------------------------------------ +" C_ApplyFlag {{{1 +"------------------------------------------------------------------------------ +function! C_ApplyFlag ( val, flag ) + " + " l : lowercase + if a:flag == ':l' + return tolower(a:val) + endif + " + " u : uppercase + if a:flag == ':u' + return toupper(a:val) + endif + " + " c : capitalize + if a:flag == ':c' + return toupper(a:val[0]).a:val[1:] + endif + " + " L : legalized name + if a:flag == ':L' + return C_LegalizeName(a:val) + endif + " + " flag not valid + return a:val +endfunction " ---------- end of function C_ApplyFlag ---------- +" +"------------------------------------------------------------------------------ +" C_ExpandSingleMacro {{{1 +"------------------------------------------------------------------------------ +function! C_ExpandSingleMacro ( val, macroname, replacement ) + return substitute( a:val, escape(a:macroname, '$' ), a:replacement, "g" ) +endfunction " ---------- end of function C_ExpandSingleMacro ---------- + +"------------------------------------------------------------------------------ +" C_SetSmallCommentStyle {{{1 +"------------------------------------------------------------------------------ +function! C_SetSmallCommentStyle () + if has_key( s:C_Template, 'comment.end-of-line-comment' ) + if match( s:C_Template['comment.end-of-line-comment'], '^\s*/\*' ) != -1 + let s:C_Com1 = '/*' " C-style : comment start + let s:C_Com2 = '*/' " C-style : comment end + else + let s:C_Com1 = '//' " C++style : comment start + let s:C_Com2 = '' " C++style : comment end + endif + endif +endfunction " ---------- end of function C_SetSmallCommentStyle ---------- + +"------------------------------------------------------------------------------ +" C_InsertMacroValue {{{1 +"------------------------------------------------------------------------------ +function! C_InsertMacroValue ( key ) + if s:C_Macro['|'.a:key.'|'] == '' + echomsg 'the tag |'.a:key.'| is empty' + return + endif + " + if &foldenable && foldclosed(".") >= 0 + echohl WarningMsg | echomsg s:MsgInsNotAvail | echohl None + return + endif + if col(".") > 1 + exe 'normal a'.s:C_Macro['|'.a:key.'|'] + else + exe 'normal i'.s:C_Macro['|'.a:key.'|'] + endif +endfunction " ---------- end of function C_InsertMacroValue ---------- + +"------------------------------------------------------------------------------ +" insert date and time {{{1 +"------------------------------------------------------------------------------ +function! C_InsertDateAndTime ( format ) + if &foldenable && foldclosed(".") >= 0 + echohl WarningMsg | echomsg s:MsgInsNotAvail | echohl None + return "" + endif + if col(".") > 1 + exe 'normal a'.C_DateAndTime(a:format) + else + exe 'normal i'.C_DateAndTime(a:format) + endif +endfunction " ---------- end of function C_InsertDateAndTime ---------- + +"------------------------------------------------------------------------------ +" generate date and time {{{1 +"------------------------------------------------------------------------------ +function! C_DateAndTime ( format ) + if a:format == 'd' + return strftime( s:C_FormatDate ) + elseif a:format == 't' + return strftime( s:C_FormatTime ) + elseif a:format == 'dt' + return strftime( s:C_FormatDate ).' '.strftime( s:C_FormatTime ) + elseif a:format == 'y' + return strftime( s:C_FormatYear ) + endif +endfunction " ---------- end of function C_DateAndTime ---------- + +"------------------------------------------------------------------------------ +" check for header or implementation file {{{1 +"------------------------------------------------------------------------------ +function! C_InsertTemplateWrapper () + if index( s:C_SourceCodeExtensionsList, expand('%:e') ) >= 0 + call C_InsertTemplate("comment.file-description") + else + call C_InsertTemplate("comment.file-description-header") + endif +endfunction " ---------- end of function C_InsertTemplateWrapper ---------- + +" +"------------------------------------------------------------------------------- +" Comment : C/C++ File Sections {{{1 +"------------------------------------------------------------------------------- +let s:CFileSection = { + \ "Header\ File\ Includes" : "file-section-cpp-header-includes" , + \ "Local\ Macros" : "file-section-cpp-macros" , + \ "Local\ Type\ Def\." : "file-section-cpp-typedefs" , + \ "Local\ Data\ Types" : "file-section-cpp-data-types" , + \ "Local\ Variables" : "file-section-cpp-local-variables" , + \ "Local\ Prototypes" : "file-section-cpp-prototypes" , + \ "Exp\.\ Function\ Def\." : "file-section-cpp-function-defs-exported" , + \ "Local\ Function\ Def\." : "file-section-cpp-function-defs-local" , + \ "Local\ Class\ Def\." : "file-section-cpp-class-defs" , + \ "Exp\.\ Class\ Impl\." : "file-section-cpp-class-implementations-exported", + \ "Local\ Class\ Impl\." : "file-section-cpp-class-implementations-local" , + \ "All\ sections,\ C" : "c", + \ "All\ sections,\ C++" : "cpp", + \ } + +function! C_CFileSectionList ( ArgLead, CmdLine, CursorPos ) + return filter( copy( sort(keys( s:CFileSection)) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) +endfunction " ---------- end of function C_CFileSectionList ---------- + +function! C_CFileSectionListInsert ( arg ) + if has_key( s:CFileSection, a:arg ) + if s:CFileSection[a:arg] == 'c' || s:CFileSection[a:arg] == 'cpp' + call C_Comment_C_SectionAll( 'comment.'.s:CFileSection[a:arg] ) + return + endif + call C_InsertTemplate( 'comment.'.s:CFileSection[a:arg] ) + else + echomsg "entry ".a:arg." does not exist" + endif +endfunction " ---------- end of function C_CFileSectionListInsert ---------- +" +"------------------------------------------------------------------------------- +" Comment : H File Sections {{{1 +"------------------------------------------------------------------------------- +let s:HFileSection = { + \ "Header\ File\ Includes" : "file-section-hpp-header-includes" , + \ "Exported\ Macros" : "file-section-hpp-macros" , + \ "Exported\ Type\ Def\." : "file-section-hpp-exported-typedefs" , + \ "Exported\ Data\ Types" : "file-section-hpp-exported-data-types" , + \ "Exported\ Variables" : "file-section-hpp-exported-variables" , + \ "Exported\ Funct\.\ Decl\." : "file-section-hpp-exported-function-declarations", + \ "Exported\ Class\ Def\." : "file-section-hpp-exported-class-defs" , + \ "All\ sections,\ C" : "c" , + \ "All\ sections,\ C++" : "cpp" , + \ } + +function! C_HFileSectionList ( ArgLead, CmdLine, CursorPos ) + return filter( copy( sort(keys( s:HFileSection)) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) +endfunction " ---------- end of function C_HFileSectionList ---------- + +function! C_HFileSectionListInsert ( arg ) + if has_key( s:HFileSection, a:arg ) + if s:HFileSection[a:arg] == 'c' || s:HFileSection[a:arg] == 'cpp' + call C_Comment_C_SectionAll( 'comment.'.s:HFileSection[a:arg] ) + return + endif + call C_InsertTemplate( 'comment.'.s:HFileSection[a:arg] ) + else + echomsg "entry ".a:arg." does not exist" + endif +endfunction " ---------- end of function C_HFileSectionListInsert ---------- +" +"------------------------------------------------------------------------------- +" Comment : Keyword Comments {{{1 +"------------------------------------------------------------------------------- +let s:KeywordComment = { + \ 'BUG' : 'keyword-bug', + \ 'COMPILER' : 'keyword-compiler', + \ 'TODO' : 'keyword-todo', + \ 'TRICKY' : 'keyword-tricky', + \ 'WARNING' : 'keyword-warning', + \ 'WORKAROUND' : 'keyword-workaround', + \ 'new\ keyword' : 'keyword-keyword', + \ } + +function! C_KeywordCommentList ( ArgLead, CmdLine, CursorPos ) + return filter( copy( sort(keys( s:KeywordComment)) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) +endfunction " ---------- end of function C_KeywordCommentList ---------- + +function! C_KeywordCommentListInsert ( arg ) + if has_key( s:KeywordComment, a:arg ) + if s:KeywordComment[a:arg] == 'c' || s:KeywordComment[a:arg] == 'cpp' + call C_Comment_C_SectionAll( 'comment.'.s:KeywordComment[a:arg] ) + return + endif + call C_InsertTemplate( 'comment.'.s:KeywordComment[a:arg] ) + else + echomsg "entry ".a:arg." does not exist" + endif +endfunction " ---------- end of function C_KeywordCommentListInsert ---------- +" +"------------------------------------------------------------------------------- +" Comment : Special Comments {{{1 +"------------------------------------------------------------------------------- +let s:SpecialComment = { + \ 'EMPTY' : 'special-empty' , + \ 'FALL\ THROUGH' : 'special-fall-through' , + \ 'IMPL\.\ TYPE\ CONV' : 'special-implicit-type-conversion")' , + \ 'NO\ RETURN' : 'special-no-return' , + \ 'NOT\ REACHED' : 'special-not-reached' , + \ 'TO\ BE\ IMPL\.' : 'special-remains-to-be-implemented' , + \ 'constant\ type\ is\ long\ (L)' : 'special-constant-type-is-long' , + \ 'constant\ type\ is\ unsigned\ (U)' : 'special-constant-type-is-unsigned' , + \ 'constant\ type\ is\ unsigned\ long\ (UL)' : 'special-constant-type-is-unsigned-long' , + \ } + +function! C_SpecialCommentList ( ArgLead, CmdLine, CursorPos ) + return filter( copy( sort(keys( s:SpecialComment)) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) +endfunction " ---------- end of function C_SpecialCommentList ---------- + +function! C_SpecialCommentListInsert ( arg ) + if has_key( s:SpecialComment, a:arg ) + if s:SpecialComment[a:arg] == 'c' || s:SpecialComment[a:arg] == 'cpp' + call C_Comment_C_SectionAll( 'comment.'.s:SpecialComment[a:arg] ) + return + endif + call C_InsertTemplate( 'comment.'.s:SpecialComment[a:arg] ) + else + echomsg "entry ".a:arg." does not exist" + endif +endfunction " ---------- end of function C_SpecialCommentListInsert ---------- + +"------------------------------------------------------------------------------- +" Standard Library Includes +"------------------------------------------------------------------------------- +function! C_CleanDirNameList ( list ) + let result = copy( a:list ) + let index = 0 + while index < len( result ) + let result[index] = substitute( result[index], '[&\\]', '', 'g' ) + let index = index + 1 + endwhile + return result +endfunction " ---------- end of function C_CleanDirNameList ---------- + +let s:C_StandardLibsClean = C_CleanDirNameList( s:C_StandardLibs ) +let s:C_C99LibsClean = C_CleanDirNameList( s:C_C99Libs ) +let s:Cpp_StandardLibsClean = C_CleanDirNameList( s:Cpp_StandardLibs ) +let s:Cpp_CStandardLibsClean = C_CleanDirNameList( s:Cpp_CStandardLibs ) + +"------------------------------------------------------------------------------- +" callback functions used in the filetype plugin ftplugin/c.vim +" callback functions +"------------------------------------------------------------------------------- + +function! C_IncludesInsert ( arg, List ) + if index( a:List, a:arg ) >= 0 + let zz = "#include\t<".a:arg.'>' + put =zz + else + echomsg "entry ".a:arg." does not exist" + endif +endfunction " ---------- end of function C_IncludesInsert +" +function! C_StdLibraryIncludesInsert ( arg ) + call C_IncludesInsert ( a:arg, s:C_StandardLibsClean ) +endfunction " ---------- end of function C_StdLibraryIncludesInsert + +function! C_C99LibraryIncludesInsert ( arg ) + call C_IncludesInsert ( a:arg, s:C_C99LibsClean ) +endfunction " ---------- end of function C_C99LibraryIncludesInsert + +function! C_CppLibraryIncludesInsert ( arg ) + call C_IncludesInsert ( a:arg, s:Cpp_StandardLibsClean ) +endfunction " ---------- end of function C_CppLibraryIncludesInsert + +function! C_CppCLibraryIncludesInsert ( arg ) + call C_IncludesInsert ( a:arg, s:Cpp_CStandardLibsClean ) +endfunction " ---------- end of function C_CppCLibraryIncludesInsert + +"------------------------------------------------------------------------------- +" callback functions used in the filetype plugin ftplugin/c.vim +" custom completion +"------------------------------------------------------------------------------- + +function! C_IncludesList ( ArgLead, CmdLine, CursorPos, List ) + " show all libs + if a:ArgLead == '' + return a:List + endif + " show libs beginning with a:ArgLead + let expansions = [] + for item in a:List + if match( item, '\<'.a:ArgLead.'\w*' ) == 0 + call add( expansions, item ) + endif + endfor + return expansions +endfunction " ---------- end of function C_IncludesList ---------- +" +function! C_StdLibraryIncludesList ( ArgLead, CmdLine, CursorPos ) + return C_IncludesList ( a:ArgLead, a:CmdLine, a:CursorPos, s:C_StandardLibsClean ) +endfunction " ---------- end of function C_StdLibraryIncludesList ---------- + +function! C_C99LibraryIncludesList ( ArgLead, CmdLine, CursorPos ) + return C_IncludesList ( a:ArgLead, a:CmdLine, a:CursorPos, s:C_C99LibsClean ) +endfunction " ---------- end of function C_C99LibraryIncludesList ---------- + +function! C_CppLibraryIncludesList ( ArgLead, CmdLine, CursorPos ) + return C_IncludesList ( a:ArgLead, a:CmdLine, a:CursorPos, s:Cpp_StandardLibsClean ) +endfunction " ---------- end of function C_CppLibraryIncludesList ---------- + +function! C_CppCLibraryIncludesList ( ArgLead, CmdLine, CursorPos ) + return C_IncludesList ( a:ArgLead, a:CmdLine, a:CursorPos, s:Cpp_CStandardLibsClean ) +endfunction " ---------- end of function C_CppCLibraryIncludesList ---------- + +"------------------------------------------------------------------------------ +" show / hide the c-support menus +" define key mappings (gVim only) +"------------------------------------------------------------------------------ +" +if has("gui_running") + " + call C_ToolMenu() + " + if s:C_LoadMenus == 'yes' + call C_CreateGuiMenus() + endif + " + nmap <unique> <silent> <Leader>lcs :call C_CreateGuiMenus()<CR> + nmap <unique> <silent> <Leader>ucs :call C_RemoveGuiMenus()<CR> + " +endif + +"------------------------------------------------------------------------------ +" Automated header insertion +" Local settings for the quickfix window +"------------------------------------------------------------------------------ + +if has("autocmd") + " + " Automated header insertion (suffixes from the gcc manual) + " + if !exists( 'g:C_Styles' ) + "------------------------------------------------------------------------------- + " template styles are the default settings + "------------------------------------------------------------------------------- + autocmd BufNewFile * if (&filetype=='cpp' || &filetype=='c') | + \ call C_InsertTemplateWrapper() | endif + " + " *.h has filetype 'cpp' by default; this can be changed to 'c' : + " + if s:C_TypeOfH=='c' + autocmd BufNewFile,BufEnter *.h :set filetype=c + endif + " + " C/C++ source code files which should not be preprocessed. + " + autocmd BufNewFile,BufRead *.i :set filetype=c + autocmd BufNewFile,BufRead *.ii :set filetype=cpp + " + else + "------------------------------------------------------------------------------- + " template styles are related to file extensions + "------------------------------------------------------------------------------- + for [ pattern, stl ] in items( g:C_Styles ) + exe "autocmd BufNewFile,BufRead,BufEnter ".pattern." call C_Style( '".stl."' )" + exe "autocmd BufNewFile ".pattern." call C_InsertTemplateWrapper() | :w!" + endfor + " + endif + " + " Wrap error descriptions in the quickfix window. + " + autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak + " + exe 'autocmd BufRead *.'.join( s:C_SourceCodeExtensionsList, '\|*.' ) + \ .' call C_HighlightJumpTargets()' + " +endif " has("autocmd") +" +"------------------------------------------------------------------------------ +" READ THE TEMPLATE FILES +"------------------------------------------------------------------------------ +call C_ReadTemplates(s:C_GlobalTemplateFile) +if s:installation == 'system' && filereadable( s:C_LocalTemplateFile ) + call C_ReadTemplates( s:C_LocalTemplateFile ) +endif +" +"===================================================================================== +" vim: tabstop=2 shiftwidth=2 foldmethod=marker diff --git a/.vim/plugin/crefvim.vim b/.vim/plugin/crefvim.vim new file mode 100755 index 0000000..db0c757 --- /dev/null +++ b/.vim/plugin/crefvim.vim @@ -0,0 +1,356 @@ +"***************************************************************************** +"** Name: crefvim.vim - a C-Reference for Vim ** +"** ** +"** Type: global VIM plugin ** +"** ** +"** Author: Christian Habermann ** +"** christian(at)habermann-net(point)de ** +"** ** +"** Copyright: (c) 2002, 2003 by Christian Habermann ** +"** ** +"** License: GNU General Public License 2 (GPL 2) or later ** +"** ** +"** This program is free software; you can redistribute it ** +"** and/or modify it under the terms of the GNU General Public ** +"** License as published by the Free Software Foundation; either ** +"** version 2 of the License, or (at your option) any later ** +"** version. ** +"** ** +"** This program is distributed in the hope that it will be ** +"** useful, but WITHOUT ANY WARRANTY; without even the implied ** +"** warrenty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ** +"** PURPOSE. ** +"** See the GNU General Public License for more details. ** +"** ** +"** Version: 1.0.0 ** +"** tested under Linux (vim, gvim 6.1) and Win32 (gvim 6.1) ** +"** ** +"** History: 0.1.0 12. Dec. 2002 - 23. Feb. 2003 ** +"** initial version, not released ** +"** 1.0.0 6. Apr. 2003 ** +"** no changes, first release ** +"** ** +"** ** +"***************************************************************************** +"** Description: ** +"** This script's intention is to provide a C-reference manual that can ** +"** be accessed from within Vim. ** +"** ** +"** For futher information see crefvim.txt or do :help crefvim ** +"** ** +"** ** +"** Happy viming... ** +"***************************************************************************** + +" allow user to avoid loading this plugin and prevent loading twice +if exists ("loaded_crefvim") + finish +endif + +let loaded_crefvim = 1 + + + + +"***************************************************************************** +"************************** C O N F I G U R A T I O N ************************ +"***************************************************************************** + +" the mappings: +if !hasmapto('<Plug>CRV_CRefVimVisual') + vmap <silent> <unique> <Leader>cr <Plug>CRV_CRefVimVisual +endif +if !hasmapto('<Plug>CRV_CRefVimNormal') + nmap <silent> <unique> <Leader>cr <Plug>CRV_CRefVimNormal +endif +if !hasmapto('<Plug>CRV_CRefVimAsk') + map <silent> <unique> <Leader>cw <Plug>CRV_CRefVimAsk +endif +if !hasmapto('<Plug>CRV_CRefVimInvoke') + map <silent> <unique> <Leader>cc <Plug>CRV_CRefVimInvoke +endif + +vmap <silent> <unique> <script> <Plug>CRV_CRefVimVisual y:call <SID>CRV_CRefVimWord('<c-r>"')<CR> +nmap <silent> <unique> <script> <Plug>CRV_CRefVimNormal :call <SID>CRV_CRefVimWord(expand("<cword>"))<CR> +map <silent> <unique> <script> <Plug>CRV_CRefVimAsk :call <SID>CRV_CRefVimAskForWord()<CR> +map <silent> <unique> <script> <Plug>CRV_CRefVimInvoke :call <SID>CRV_CRefVimShowContents()<CR> + + + + +"***************************************************************************** +"************************* I N I T I A L I S A T I O N *********************** +"***************************************************************************** + + +"***************************************************************************** +"****************** I N T E R F A C E T O C O R E ************************** +"***************************************************************************** + +"***************************************************************************** +"** this function separates plugin-core-function from user ** +"***************************************************************************** +function <SID>CRV_CRefVimWord(str) + call s:CRefVim(a:str) +endfunction + + +"***************************************************************************** +"** this function separates plugin-core-function from user ** +"***************************************************************************** +function <SID>CRV_CRefVimAskForWord() + call s:CRefVimAskForWord() +endfunction + + +"***************************************************************************** +"** this function separates plugin-core-function from user ** +"***************************************************************************** +function <SID>CRV_CRefVimShowContents() + " show contents of C-reference manual + call s:LookUp("") +endfunction + + + + + +"***************************************************************************** +"************************ C O R E F U N C T I O N S ************************* +"***************************************************************************** + +"***************************************************************************** +"** ask for a word/phrase and lookup ** +"***************************************************************************** +function s:CRefVimAskForWord() + let l:strng = input("What to lookup: ") + call s:LookUp(l:strng) +endfunction + + + +"***************************************************************************** +"** input: "str" ** +"** output: empty string: "str" is not an operator ** +"** else: name of tag to go to ** +"** ** +"***************************************************************************** +"** remarks: ** +"** This function tests whether or not "str" is an operator. ** +"** If so, the tag to go to is returned. ** +"** ** +"***************************************************************************** +function s:IsItAnOperator(str) + + " get first character + let l:firstChr = strpart(a:str, 0, 1) + + " is the first character of the help-string an operator? + if stridx("!&+-*/%,.:<=>?^|~(){}[]", l:firstChr) >= 0 + return "crv-operators" + else + return "" + endif + +endfunction + + + +"***************************************************************************** +"** input: "str" ** +"** output: empty string: "str" is not an escape-sequence ** +"** else: name of tag to go to ** +"** ** +"***************************************************************************** +"** remarks: ** +"** This function tests whether or not "str" is an escape-sequence. ** +"** If so, the tag to go to is returned. ** +"** Note: currently \' does not work (="\\\'") ** +"** ** +"***************************************************************************** +function s:IsItAnEscSequence(str) + + if (a:str == "\\") || (a:str == "\\\\") || (a:str == "\\0") || (a:str == "\\x") || + \(a:str == "\\a") || (a:str == "\\b") || (a:str == "\\f") || (a:str == "\\n") || + \(a:str == "\\r") || (a:str == "\\t") || (a:str == "\\v") || (a:str == "\\?") || + \(a:str == "\\\'") || (a:str == "\\\"") + return "crv-lngEscSeq" + else + return "" + endif + +endfunction + + + + +"***************************************************************************** +"** input: "str" ** +"** output: empty string: "str" is not a comment ** +"** else: name of tag to go to ** +"** ** +"***************************************************************************** +"** remarks: ** +"** This function tests whether or not "str" is a comment. ** +"** If so, the tag to go to is returned. ** +"** ** +"***************************************************************************** +function s:IsItAComment(str) + + if (a:str == "//") || (a:str == "/*") || (a:str == "*/") + return "crv-lngComment" + else + return "" + endif + +endfunction + + + + +"***************************************************************************** +"** input: "str" ** +"** output: empty string: "str" is not a preprocessor ** +"** else: name of tag to go to ** +"** ** +"***************************************************************************** +"** remarks: ** +"** This function tests whether or not "str" is a preprocessor command ** +"** or a preprocessor operator. ** +"** If so, the tag to go to is returned. ** +"** ** +"** Nothing is done if the help-string is equal to "if" or "else" ** +"** because these are statements too. For "if" and "else" it's assumed ** +"** that the statements are meant. But "#if" and "#else" are treated ** +"** as preprocessor commands. ** +"** ** +"***************************************************************************** +function s:IsItAPreprocessor(str) + + " get first character + let l:firstChr = strpart(a:str, 0, 1) + + " if first character of the help-string is a #, we have the command/operator + " string in an appropriate form, so append this help-string to "crv-" + if l:firstChr == "#" + return "crv-" . a:str + else + " no # in front of the help string, so evaluate which command/operator + " is meant + if (a:str == "defined") + return "crv-defined" + else + if (a:str == "define") || + \(a:str == "undef") || + \(a:str == "ifdef") || + \(a:str == "ifndef") || + \(a:str == "elif") || + \(a:str == "endif") || + \(a:str == "include") || + \(a:str == "line") || + \(a:str == "error") || + \(a:str == "pragma") + return "\#" . a:str + endif + endif + endif + +endfunction + + + + +"***************************************************************************** +"** input: "str" to lookup in C-reference manual ** +"** output: none ** +"***************************************************************************** +"** remarks: ** +"** Lookup string "str". ** +"** Generally this function calls :help crv-"str" where "str" is the ** +"** word for which the user wants some help. ** +"** ** +"** But before activating VIM's help-system some tests and/or ** +"** modifications are done on "str": ** +"** - if help-string is a comment (//, /* or */), go to section ** +"** describing comments ** +"** - if help-string is an escape-sequence, go to section describing ** +"** escape-sequences ** +"** - if help-string is an operator, go to section dealing with operators ** +"** - if help-string is a preprocessor command/operator, go to section ** +"** that describes that command/operator ** +"** - else call :help crv-"str" ** +"** ** +"** If the help-string is empty, go to contents of C-reference manual. ** +"** ** +"***************************************************************************** +function s:LookUp(str) + + if a:str != "" + + let l:helpTag = s:IsItAComment(a:str) + + if l:helpTag == "" + let l:helpTag = s:IsItAnEscSequence(a:str) + + if l:helpTag == "" + let l:helpTag = s:IsItAnOperator(a:str) + + if l:helpTag == "" + let l:helpTag = s:IsItAPreprocessor(a:str) + + if l:helpTag == "" + let l:helpTag = "crv-" . a:str + endif + + endif + + endif + + endif + + + " reset error message + let v:errmsg = "" + + " activate help-system looking for the appropriate topic + " suppress error messages + silent! execute ":help " . l:helpTag + + " if there was an error, print message + if v:errmsg != "" + echo " No help found for \"" .a:str . "\"" + endif + else + " help string is empty, so show contents of manual + execute ":help crefvim" + endif + + +endfunction + + + +"***************************************************************************** +"** input: "str" to lookup in C-reference manual ** +"** output: none ** +"***************************************************************************** +"** remarks: ** +"** lookup string "str". ** +"** If there is no string, ask for word/phrase. ** +"** ** +"***************************************************************************** +function s:CRefVim(str) + + let s:strng = a:str + + if s:strng == "" " is there a string to search for? + call s:CRefVimAskForWord() + else + call s:LookUp(s:strng) + endif + +endfunction + + + +"*** EOF *** diff --git a/.vim/plugin/cscope_maps.vim b/.vim/plugin/cscope_maps.vim new file mode 100644 index 0000000..c577b45 --- /dev/null +++ b/.vim/plugin/cscope_maps.vim @@ -0,0 +1,165 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" CSCOPE settings for vim +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +" This file contains some boilerplate settings for vim's cscope interface, +" plus some keyboard mappings that I've found useful. +" +" USAGE: +" -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a +" 'plugin' directory in some other directory that is in your +" 'runtimepath'. +" +" -- vim 5: Stick this file somewhere and 'source cscope.vim' it from +" your ~/.vimrc file (or cut and paste it into your .vimrc). +" +" NOTE: +" These key maps use multiple keystrokes (2 or 3 keys). If you find that vim +" keeps timing you out before you can complete them, try changing your timeout +" settings, as explained below. +" +" Happy cscoping, +" +" Jason Duell jduell@alumni.princeton.edu 2002/3/7 +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + + +" This tests to see if vim was configured with the '--enable-cscope' option +" when it was compiled. If it wasn't, time to recompile vim... +if has("cscope") + + """"""""""""" Standard cscope/vim boilerplate + + " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t' + set cscopetag + + " check cscope for definition of a symbol before checking ctags: set to 1 + " if you want the reverse search order. + set csto=0 + + " add any cscope database in current directory + if filereadable("cscope.out") + cs add cscope.out + " else add the database pointed to by environment variable + elseif $CSCOPE_DB != "" + cs add $CSCOPE_DB + endif + + " show msg when any other cscope db added + set cscopeverbose + + + """"""""""""" My cscope/vim key mappings + " + " The following maps all invoke one of the following cscope search types: + " + " 's' symbol: find all references to the token under cursor + " 'g' global: find global definition(s) of the token under cursor + " 'c' calls: find all calls to the function name under cursor + " 't' text: find all instances of the text under cursor + " 'e' egrep: egrep search for the word under cursor + " 'f' file: open the filename under cursor + " 'i' includes: find files that include the filename under cursor + " 'd' called: find functions that function under cursor calls + " + " Below are three sets of the maps: one set that just jumps to your + " search result, one that splits the existing vim window horizontally and + " diplays your search result in the new window, and one that does the same + " thing, but does a vertical split instead (vim 6 only). + " + " I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's + " unlikely that you need their default mappings (CTRL-\'s default use is + " as part of CTRL-\ CTRL-N typemap, which basically just does the same + " thing as hitting 'escape': CTRL-@ doesn't seem to have any default use). + " If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all + " of these maps to use other keys. One likely candidate is 'CTRL-_' + " (which also maps to CTRL-/, which is easier to type). By default it is + " used to switch between Hebrew and English keyboard mode. + " + " All of the maps involving the <cfile> macro use '^<cfile>$': this is so + " that searches over '#include <time.h>" return only references to + " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all + " files that contain 'time.h' as part of their name). + + + " To do the first type of search, hit 'CTRL-\', followed by one of the + " cscope search types above (s,g,c,t,e,f,i,d). The result of your cscope + " search will be displayed in the current window. You can use CTRL-T to + " go back to where you were before the search. + " + + nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> + nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> + nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> + nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> + nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> + nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> + nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> + nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR> + + + " Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type + " makes the vim window split horizontally, with search result displayed in + " the new window. + " + " (Note: earlier versions of vim may not have the :scs command, but it + " can be simulated roughly via: + " nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR> + + nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR> + nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR> + nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR> + nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR> + nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR> + nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR> + nmap <C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR> + nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR> + + + " Hitting CTRL-space *twice* before the search type does a vertical + " split instead of a horizontal one (vim 6 and up only) + " + " (Note: you may wish to put a 'set splitright' in your .vimrc + " if you prefer the new window on the right instead of the left + + nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR> + nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR> + nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR> + nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR> + nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR> + nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR> + nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR> + nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR> + + + """"""""""""" key map timeouts + " + " By default Vim will only wait 1 second for each keystroke in a mapping. + " You may find that too short with the above typemaps. If so, you should + " either turn off mapping timeouts via 'notimeout'. + " + "set notimeout + " + " Or, you can keep timeouts, by uncommenting the timeoutlen line below, + " with your own personal favorite value (in milliseconds): + " + "set timeoutlen=4000 + " + " Either way, since mapping timeout settings by default also set the + " timeouts for multicharacter 'keys codes' (like <F1>), you should also + " set ttimeout and ttimeoutlen: otherwise, you will experience strange + " delays as vim waits for a keystroke after you hit ESC (it will be + " waiting to see if the ESC is actually part of a key code like <F1>). + " + "set ttimeout + " + " personally, I find a tenth of a second to work well for key code + " timeouts. If you experience problems and have a slow terminal or network + " connection, set it higher. If you don't set ttimeoutlen, the value for + " timeoutlent (default: 1000 = 1 second, which is sluggish) is used. + " + "set ttimeoutlen=100 + +endif + + diff --git a/.vim/plugin/vtreeexplorer.vim b/.vim/plugin/vtreeexplorer.vim new file mode 100644 index 0000000..2458abc --- /dev/null +++ b/.vim/plugin/vtreeexplorer.vim @@ -0,0 +1,872 @@ +"" File: vtreeexplorer.vim +"" Description: tree-like file system explorer for vim +"" Version: $Revision: 1.24 $ $Date: 2005/11/17 16:24:33 $ +"" Author: TS Urban (thomas.scott.urban@HORMELgmail.com) +"" (remove the source of SPAM from my email first) +"" +"" Instructions: +"" 1 - source this file or put in your plugin directory +"" 2 - :VTreeExlorer or :VSTreeExplore +"" 3 - help at top of screen +"" 4 - this script comes with a help text that integrates with the vim help +"" system, put vtreeexplorer.txt in your ~/.vim/doc dir, then do +"" :helptags ~/.vim/doc +"" +"" Global Configuration Variables: +"" treeExplVertical : split vertically when starting with VSTreeExplore +"" treeExplWinSize : window size (width or height) when doing VSTreeExplore +"" treeExplHidden : set to have explorer start with hidden files shown +"" treeExplHidePattern : set have matching files not shown +"" treeExplDirSort : start explorer with desired directory sorting: +"" 0 : no directory sorting +"" 1 : directories sorting first +"" -1 : directories sorting last +"" treeExplIndent : width of tree indentation in spaces (min 3, max 8) +"" treeExplNoList : don't list the explorer in the buffer list +"" +"" Todo: +"" - global option for path separator +"" - merge in patches for winmanager +"" - +/- keymappings, etc +"" - recursively collapse binding/function + +"" prevent multiple loading unless developing with g:treeExplDebug +if exists("vloaded_tree_explorer") && !exists("g:treeExplDebug") + finish +endif +let vloaded_tree_explorer=1 + +let s:cpo_save = &cpo +set cpo&vim + +"" create commands +command! -n=? -complete=dir VTreeExplore :call s:TreeExplorer(0, '<args>') +command! -n=? -complete=dir VSTreeExplore :call s:TreeExplorer(1, '<args>') + +"" support sessions +autocmd BufNewFile TreeExplorer VTreeExplore + +"" create a string of chr cnt long - emulate vim7 repeat function +function! s:MyRepeat(chr, cnt) " <<< + let sret = "" + let lcnt = a:cnt + while lcnt > 0 + let sret = sret . a:chr + let lcnt = lcnt - 1 + endwhile + return sret +endf " >>> + +function! s:InitWindowVars() " <<< + if exists("w:tree_vars_defined") + return + endif + + let w:tree_vars_defined = 1 + + let w:escape_chars = " `|\"~'#" + + " win specific vars from globals if they exist + let w:hidden_files = (exists("g:treeExplHidden")) ? 1 : 0 + let w:dirsort = (exists("g:treeExplDirSort")) ? g:treeExplDirSort : 0 + if w:dirsort < -1 || w:dirsort > 1 + let w:dirsort = 0 + let w:escape_chars = w:escape_chars . '+' + endif + + " tree visual widget configuration, width limited to range [3,16] + let w:tree_wid_ind = (exists("g:treeExplIndent")) ? g:treeExplIndent : 3 + let w:tree_wid_ind = (w:tree_wid_ind < 3) ? 3 : w:tree_wid_ind + let w:tree_wid_ind = (w:tree_wid_ind > 8) ? 16 : w:tree_wid_ind + + let bar_char = '|' + let dsh_char = '-' + let grv_char = '`' + let spc_char = ' ' + + let w:tree_par_wid = bar_char . s:MyRepeat (spc_char, w:tree_wid_ind - 2) . spc_char + let w:tree_dir_wid = bar_char . s:MyRepeat (dsh_char, w:tree_wid_ind - 2) . spc_char + let w:tree_end_wid = grv_char . s:MyRepeat (dsh_char, w:tree_wid_ind - 2) . spc_char + let w:tree_spc_wid = s:MyRepeat (spc_char, w:tree_wid_ind) + + " init help to short version + let w:helplines = 1 + +endfunction " >>> + +"" TreeExplorer() - set up explorer window +function! s:TreeExplorer(split, start) " <<< + + " dir to start in from arg, buff dir, or pwd + let fname = (a:start != "") ? a:start : expand ("%:p:h") + let fname = (fname != "") ? fname : getcwd () + + " construct command to open window + if a:split || &modified + " if starting with split, get split parameters from globals + let splitMode = (exists("g:treeExplVertical")) ? "vertical " : "" + let splitSize = (exists("g:treeExplWinSize")) ? g:treeExplWinSize : 20 + let cmd = splitMode . splitSize . "new TreeExplorer" + else + let cmd = "e TreeExplorer" + endif + silent execute cmd + + call s:InitWindowVars() + + "" chars to escape in file/dir names - TODO '+' ? + " throwaway buffer options + setlocal noswapfile + setlocal buftype=nowrite + setlocal bufhidden=delete " d + setlocal nowrap + setlocal foldcolumn=0 + + if exists("g:treeExplNoList") + setlocal nobuflisted + endif + if has('spell') + setlocal nospell + endif + iabc <buffer> + + " setup folding for markers that will be inserted + setlocal foldmethod=marker + setlocal foldtext=substitute(getline(v:foldstart),'.{{{.*','','') + setlocal foldlevel=1 + + " syntax highlighting + if has("syntax") && exists("g:syntax_on") && !has("syntax_items") + syn match treeHlp #^" .*# + syn match treeDir "^\.\. (up a directory)$" + + syn match treeFld "{{{" + syn match treeFld "}}}" + + execute "syn match treePrt #" . w:tree_par_wid . "#" + execute "syn match treePrt #" . w:tree_dir_wid . "#" + execute "syn match treePrt #" . w:tree_end_wid . "#" + + syn match treeLnk #[^-| `].* -> # contains=treeFld + syn match treeDir #[^-| `].*/\([ {}]\{4\}\)*$# contains=treeFld,treeLnk + syn match treeCWD #^/.*$# contains=treeFld + + hi def link treePrt Normal + hi def link treeFld Ignore + hi def link treeHlp Special + hi def link treeDir Directory + hi def link treeCWD Statement + hi def link treeLnk Title + endif + + " for line continuation + let cpo_save1 = &cpo + set cpo&vim + + " set up mappings and commands for this buffer + nnoremap <buffer> <cr> :call <SID>Activate("win")<cr> + nnoremap <buffer> o :call <SID>Activate("win")<cr> + nnoremap <buffer> O :call <SID>Activate("cur")<cr> + nnoremap <buffer> t :call <SID>Activate("tab")<cr> + nnoremap <buffer> X :call <SID>RecursiveExpand()<cr> + nnoremap <buffer> E :call <SID>OpenExplorer()<cr> + nnoremap <buffer> C :call <SID>ChangeTop()<cr> + nnoremap <buffer> H :call <SID>InitWithDir($HOME)<cr> + nnoremap <buffer> u :call <SID>ChdirUp()<cr> + nnoremap <buffer> p :call <SID>MoveParent()<cr> + nnoremap <buffer> r :call <SID>RefreshDir()<cr> + nnoremap <buffer> R :call <SID>InitWithDir("")<cr> + nnoremap <buffer> S :call <SID>StartShell()<cr> + nnoremap <buffer> D :call <SID>ToggleDirSort()<cr> + nnoremap <buffer> a :call <SID>ToggleHiddenFiles()<cr> + nnoremap <buffer> ? :call <SID>ToggleHelp()<cr> + nnoremap <buffer> <2-leftmouse> :call <SID>Activate("win")<cr> + + command! -buffer -complete=dir -nargs=1 CD :call s:TreeCD('<args>') + command! -buffer -range -nargs=0 Yank :<line1>,<line2>y | + \ let @" = substitute (@", ' [{}]\{3\}', "", "g") + + let &cpo = cpo_save1 " restore + + call s:InitWithDir(fname) " load fname dir +endfunction " >>> + +"" TreeCD() - change to dir from cmdline arg +function! s:TreeCD(dir) " <<< + if isdirectory (a:dir) + call s:InitWithDir (a:dir) + else + echo "can not change to directory: " . a:dir + endif +endfunction " >>> + +"" InitWithDir() - reload tree with dir +function! s:InitWithDir(dir) " <<< + call s:InitWindowVars() + + if a:dir != "" + try + execute "lcd " . escape (a:dir, w:escape_chars) + catch + echo "ERROR: changing to directory: " . a:dir + return + endtry + endif + let cwd = getcwd () + + if has("unix") == 0 + let cwd = substitute (cwd, '\\', '/', "g") + let is_root = (cwd =~ '^[A-Z]:/$') ? 1 : 0 + else + let is_root = (cwd == "/") ? 1 : 0 + endif + + let cwd = substitute (cwd, '/*$', '/', "") + + let save_f = @f + let save_y = @" + + " clear buffer + setlocal modifiable | silent! normal ggdG + setlocal nomodifiable + + "insert header + call s:AddHeader() + normal G + + "insert parent link unless we're at / for unix or X:\ for dos + if is_root == 0 + let @f=".. (up a directory)" + endif + let @f=@f . "\n" . cwd . "\n\n" + + setlocal modifiable | silent put f | setlocal nomodifiable + + normal Gk + + call s:ReadDir (line("."), cwd) " read dir + + let @f = save_f + let @" = save_y +endfunction " >>> + +"" ReadDir() - read dir after current line with tree pieces and foldmarkers +function! s:ReadDir(lpn,dir) " <<< + let olddir = getcwd () + + let lps = getline (a:lpn) + + if a:dir == "" + let dir = GetAbsPath2 (lpn, 0) + if w:firstdirline ! = lpn + echo "ERROR" + return + endif + else + let dir = a:dir + endif + + " TODO - error when dir no longer exists + try + execute "lcd " . escape (dir, w:escape_chars) + catch + echo "ERROR: changing to directory: " . dir + return + endtry + + """ THIS BLOCK DOESN' DO ANYTHING + " change dos path to look like unix path + "if has("unix") == 0 " TODO - so many dos/win variants, this seemed easier - maybe not correct (e.g. OS2, mac, etc) + " let dir = substitute (dir, '\\', '/', "g") + "endif + "let dir = substitute (dir, '/\?$', '/', "") + """ THIS BLOCK DOESN' DO ANYTHING + + " get dir contents + if w:hidden_files == 1 + let dirlines = glob ('.*') . "\n" . glob ('*') + else + let dirlines = glob ('*') + endif + + " if empty, don't change line + if dirlines == "" + return + endif + + let treeprt = substitute (lps, '[^-| `].*', "", "") + let pdirprt = substitute (lps, '^[-| `]*', "", "") + let pdirprt = substitute (pdirprt, '[{} ]*$', "", "") + let foldprt = substitute (lps, '.*' . pdirprt, "", "") + + " save states of registers for restoring + " @l is used for first line, last line, and if dir sorting is off + " @f and @d are used for file and dirs with dir sorting + let save_l = @l | let @l = "" + let save_d = @d | let @d = "" + let save_f = @f | let @f = "" + let save_y = @" + + let @l = treeprt . pdirprt . ' {{{' + + let treeprt = substitute (treeprt, w:tree_end_wid, w:tree_spc_wid, "") + let treeprt = substitute (treeprt, w:tree_dir_wid, w:tree_par_wid, "") + + " parse dir contents by '/' + let dirlines = substitute (dirlines, "\n", '/', "g") + + if exists("g:treeExplHidePattern") + let do_hide_re = 1 + else + let do_hide_re = 0 + endif + + while strlen (dirlines) > 0 + let curdir = substitute (dirlines, '/.*', "", "") + let dirlines = substitute (dirlines, '[^/]*/\?', "", "") + + if w:hidden_files == 1 && curdir =~ '^\.\.\?$' + continue + endif + + if w:hidden_files == 0 && do_hide_re == 1 && curdir =~ g:treeExplHidePattern + continue + endif + + let linkedto = resolve (curdir) + if linkedto != curdir + let curdir = curdir . ' -> ' . linkedto + endif + if isdirectory (linkedto) + let isdir = 1 + let curdir = curdir . '/' + else + let isdir = 0 + endif + + " escape leading characters confused with tree parts + if curdir =~ '^[-| `]' + let curdir = '\' . curdir + endif + + if w:dirsort != 0 + if isdir == 1 + let @d = @d . "\n" . treeprt . w:tree_dir_wid . curdir + else + let @f = @f . "\n" . treeprt . w:tree_dir_wid . curdir + endif + else + let @l = @l . "\n" . treeprt . w:tree_dir_wid . curdir + endif + endwhile + + if w:dirsort == 1 + let @l = @l . @d . @f . "\n" + elseif w:dirsort == -1 + let @l = @l . @f . @d . "\n" + else + let @l = @l . "\n" + endif + + exec (":" . a:lpn) + + " TODO handle fold open v fold closed + setlocal modifiable + silent normal ddk + silent put l + setlocal nomodifiable + + " make sure fold is open so we don't delete the whole thing + "if foldclosed (line (".")) != -1 + if foldclosed (a:lpn) != -1 + foldopen + endif + + normal! `] + + " change last tree part to the final leaf marking, add final fold mark + let @l = getline(".") + let @l = substitute (@l, w:tree_dir_wid, w:tree_end_wid, "") + let @l = @l . foldprt . " }}}\n" + + setlocal modifiable | silent normal dd + silent put! l | setlocal nomodifiable + + " restore registers + let @l = save_l + let @d = save_d + let @f = save_f + let @" = save_y + + exec (":" . a:lpn) + + execute "lcd " . escape (olddir, w:escape_chars) +endfunction " >>> + +"" ChdirUp() - cd up (if possible) +function! s:ChdirUp() " <<< + let cwd = getcwd() + if cwd == "/" || cwd =~ '^[^/]..$' + echo "already at top dir" + else + call s:InitWithDir("..") + endif +endfunction " >>> + +"" MoveParent() - move cursor to parent dir +function! s:MoveParent() " <<< + call s:InitWindowVars() + + let ln = line(".") + call s:GetAbsPath2 (ln, 1) + if w:firstdirline != 0 + exec (":" . w:firstdirline) + else + exec (":" . w:helplines) + endif +endfunction " >>> + +"" ChangeTop() - change top dir to cursor dir +function! s:ChangeTop() " <<< + call s:InitWindowVars() + + let ln = line(".") + let l = getline(ln) + + " on current top or non-tree line? + if l !~ '^[| `]' + return + endif + + " parent dir + if l =~ '^\.\. ' + call s:ChdirUp() + return + endif + + let curfile = s:GetAbsPath2(ln, 0) + if curfile !~ '/$' + let curfile = substitute (curfile, '[^/]*$', "", "") + endif + call s:InitWithDir (curfile) +endfunction " >>> + +"" RecursiveExpand() - expand cursor dir recursively +function! s:RecursiveExpand() " <<< + call s:InitWindowVars() + + echo "recursively expanding, this might take a while (CTRL-C to stop)" + + let curfile = s:GetAbsPath2(line("."), 0) + + if w:firstdirline == 0 + let init_ln = w:helplines + let curfile = substitute (getline (init_ln), '[ {]*', "", "") + else + let init_ln = w:firstdirline + endif + + let init_ind = match (getline (init_ln), '[^-| `]') / w:tree_wid_ind + + let curfile = substitute (curfile, '[^/]*$', "", "") + + let l = getline (init_ln) + + if l =~ ' {{{$' + if foldclosed (init_ln) != -1 + foldopen + endif + endif + + if l !~ ' {{{$' " dir not open + call s:ReadDir (init_ln, curfile) + + if getline (init_ln) !~ ' {{{$' " dir still not open (empty) + echo "expansion done" + return + endif + endif + + let ln = init_ln + 1 + + let l = getline (ln) + + let match_str = '[^-| `]' + while init_ind < (match (l, '[^-| `]') / w:tree_wid_ind) + let tl = l + let tln = ln + let ln = ln + 1 + let l = getline (ln) + + if tl =~ ' {{{$' + if foldclosed (tln) != -1 + foldopen + endif + continue + endif + + " link or non dir + if tl =~ ' -> ' || tl !~ '/[ }]*$' + continue + endif + + let curfile = s:GetAbsPath2(tln, 0) + + call s:ReadDir (tln, curfile) + + let l = getline (ln) + endwhile + + exec (":" . init_ln) + echo "expansion done" +endfunction " >>> + +"" OpenExplorer() - open file explorer on cursor dir +function! s:OpenExplorer() " <<< + call s:InitWindowVars() + + let curfile = s:GetAbsPath2 (line ("."), 0) + + if w:firstdirline == 0 + let curfile = getcwd () + else + " remove file name, if any + let curfile = substitute (curfile, '[^/]*$', "", "") + endif + + let curfile = escape (curfile, w:escape_chars) + + let oldwin = winnr() + wincmd p + if oldwin == winnr() || &modified + wincmd p + exec ("new " . curfile) + else + exec ("edit " . curfile) + endif + +endfunction " >>> + +"" Activate() - (un)fold read dirs, read unread dirs, open files, cd .. on .. +function! s:Activate(how) " <<< + call s:InitWindowVars() + + let ln = line(".") + let l = getline(ln) + + " parent dir, change to it + if l =~ '^\.\. (up a directory)$' + call s:ChdirUp() + return + endif + + " directory loaded, toggle folded state + if l =~ ' {{{$' + if foldclosed(ln) == -1 + foldclose + else + foldopen + endif + return + endif + + " on top, no folds, or not on tree + if l !~ '^[-| `]' + return + endif + + " get path of line + let curfile = s:GetAbsPath2 (ln, 0) + + if curfile =~ '/$' " dir + call s:ReadDir (ln, curfile) + return + else " file + let f = escape (curfile, w:escape_chars) + let oldwin = winnr() + wincmd p + if a:how == "tab" + exec ("tabedit " . f) + elseif a:how == "cur" + exec ("tabedit " . f) + elseif oldwin == winnr() || (&modified && s:BufInWindows(winbufnr(winnr())) < 2) + wincmd p + exec ("new " . f) + else + exec ("edit " . f) + endif + endif +endfunction " >>> + +"" RefreshDir() - refresh current dir +function! s:RefreshDir() " <<< + call s:InitWindowVars() + + let curfile = s:GetAbsPath2(line("."), 0) + + let init_ln = w:firstdirline + + " not in tree, or on path line or parent is top + if curfile == "" || init_ln == 0 + call s:InitWithDir("") + return + endif + + let save_l = @l + + " remove file name, if any + let curfile = substitute (curfile, '[^/]*$', "", "") + + let @l = getline (init_ln) + + " if there is no fold, just do normal ReadDir, and return + if @l !~ ' {{{$' + call s:ReadDir (init_ln, curfile) + let @l = save_l + return + endif + + " TODO factor + + if foldclosed(init_ln) == -1 + foldclose + endif + + " remove one foldlevel from line + let @l = substitute (@l, ' {{{$', "", "") + + exec (":" . init_ln) + + setlocal modifiable + silent normal ddk + silent put l + setlocal nomodifiable + + call s:ReadDir (init_ln, curfile) + + let @l = save_l +endfunction " >>> + +"" ToggleHiddenFiles() - toggle hidden files +function! s:ToggleHiddenFiles() " <<< + call s:InitWindowVars() + + let w:hidden_files = w:hidden_files ? 0 : 1 + let msg = w:hidden_files ? "on" : "off" + let hre = exists("g:treeExplHidePattern") ? g:treeExplHidePattern : '' + let msg = "hidden (dotfiles and regex = '" . hre . "') files now = " . msg + echo msg + call s:UpdateHeader () + call s:RefreshDir() +endfunction " >>> + +"" ToggleDirSort() - toggle dir sorting +function! s:ToggleDirSort() " <<< + call s:InitWindowVars() + + if w:dirsort == 0 + let w:dirsort = 1 + let msg = "dirs first" + elseif w:dirsort > 0 + let w:dirsort = -1 + let msg = "dirs last" + else + let w:dirsort = 0 + let msg = "off" + endif + let msg = "dirs sorting now = " . msg + echo msg + call s:UpdateHeader () + call s:RefreshDir() +endfunction " >>> + +"" StartShell() - start shell in cursor dir +function! s:StartShell() " <<< + call s:InitWindowVars() + + let ln = line(".") + + let curfile = s:GetAbsPath2 (ln, 1) + let prevdir = getcwd() + + if w:firstdirline == 0 + let dir = prevdir + else + let dir = substitute (curfile, '[^/]*$', "", "") + endif + + try + execute "lcd " . escape (dir, w:escape_chars) + shell + catch + echo "ERROR: changing to directory: " . dir + return + endtry + execute "lcd " . escape (prevdir, w:escape_chars) +endfunction " >>> + +"" GetAbsPath2() - get absolute path at line ln, set w:firstdirline, +"" - if ignore_current is 1, don't set line to current line when on a dir +function! s:GetAbsPath2(ln,ignore_current) " <<< + let lnum = a:ln + let l = getline(lnum) + + let w:firstdirline = 0 + + " in case called from outside the tree + if l =~ '^[/".]' || l =~ '^$' + return "" + endif + + let wasdir = 0 + + " strip file + let curfile = substitute (l,'^[-| `]*',"","") " remove tree parts + let curfile = substitute (curfile,'[ {}]*$',"",'') " remove fold marks + "let curfile = substitute (curfile,'[*=@|]$',"","") " remove file class + + " remove leading escape + let curfile = substitute (curfile,'^\\', "", "") + + if curfile =~ '/$' && a:ignore_current == 0 + let wasdir = 1 + let w:firstdirline = lnum + endif + + let curfile = substitute (curfile,' -> .*',"","") " remove link to + if wasdir == 1 + let curfile = substitute (curfile, '/\?$', '/', "") + endif + + let indent = match(l,'[^-| `]') / w:tree_wid_ind + + let dir = "" + while lnum > 0 + let lnum = lnum - 1 + let lp = getline(lnum) + if lp =~ '^/' + let sd = substitute (lp, '[ {]*$', "", "") + let dir = sd . dir + break + endif + if lp =~ ' {{{$' + let lpindent = match(lp,'[^-| `]') / w:tree_wid_ind + if lpindent < indent + if w:firstdirline == 0 + let w:firstdirline = lnum + endif + let indent = indent - 1 + let sd = substitute (lp, '^[-| `]*',"","") " rm tree parts + let sd = substitute (sd, '[ {}]*$', "", "") " rm foldmarks + let sd = substitute (sd, ' -> .*','/',"") " replace link to with / + + " remove leading escape + let sd = substitute (sd,'^\\', "", "") + + let dir = sd . dir + continue + endif + endif + endwhile + let curfile = dir . curfile + return curfile +endfunction " >>> + +"" ToggleHelp() - toggle between long and short help +function! s:ToggleHelp() " <<< + call s:InitWindowVars() + + let w:helplines = (w:helplines <= 4) ? 6 : 0 + call s:UpdateHeader () +endfunction " >>> + +"" Determine the number of windows open to this buffer number. +"" Care of Yegappan Lakshman. Thanks! +fun! s:BufInWindows(bnum) " <<< + let cnt = 0 + let winnum = 1 + while 1 + let bufnum = winbufnr(winnum) + if bufnum < 0 + break + endif + if bufnum == a:bnum + let cnt = cnt + 1 + endif + let winnum = winnum + 1 + endwhile + + return cnt +endfunction " >>> + +"" UpdateHeader() - update the header +function! s:UpdateHeader() " <<< + let oldRep=&report + set report=10000 + normal! mt + + " Remove old header + 0 + setlocal modifiable | silent! 1,/^" ?/ d _ | setlocal nomodifiable + + call s:AddHeader() + + " return to previous mark + 0 + if line("'t") != 0 + normal! `t + endif + + let &report=oldRep +endfunction " >>> + +"" - AddHeader() - add the header with help information +function! s:AddHeader() " <<< + if w:dirsort == 0 + let dt = "off)\n" + elseif w:dirsort == 1 + let dt = "dirs first)\n" + else + let dt = "dirs last)\n" + endif + + let hre = exists("g:treeExplHidePattern") ? g:treeExplHidePattern : "" + + let save_f=@f + 1 + let ln = 3 + if w:helplines > 4 + let ln=ln+1 | let @f= "\" o = (file) open in another window\n" + let ln=ln+1 | let @f=@f."\" o = (dir) toggle dir fold or load dir\n" + let ln=ln+1 | let @f=@f."\" <ret> = same as 'o'\n" + let ln=ln+1 | let @f=@f."\" O = same as 'o' but use replace explorer\n" + let ln=ln+1 | let @f=@f."\" t = same as 'o' but use new tab\n" + let ln=ln+1 | let @f=@f."\" X = recursive expand cursor dir\n" + let ln=ln+1 | let @f=@f."\" E = open Explorer on cursor dir\n" + let ln=ln+1 | let @f=@f."\" C = chdir top of tree to cursor dir\n" + let ln=ln+1 | let @f=@f."\" H = chdir top of tree to home dir\n" + let ln=ln+1 | let @f=@f."\" u = chdir top of tree to parent dir\n" + let ln=ln+1 | let @f=@f."\" :CD d = chdir top of tree to dir <d>\n" + let ln=ln+1 | let @f=@f."\" p = move cursor to parent dir\n" + let ln=ln+1 | let @f=@f."\" r = refresh cursor dir\n" + let ln=ln+1 | let @f=@f."\" R = refresh top dir\n" + let ln=ln+1 | let @f=@f."\" S = start a shell in cursor dir\n" + let ln=ln+1 | let @f=@f."\" :Yank = yank <range> lines withoug fold marks\n" + let ln=ln+1 | let @f=@f."\" D = toggle dir sort (now = " . dt + let ln=ln+1 | let @f=@f."\" a = toggle hidden (dotfiles and regex = '" + \ . hre . "') files (now = " + \ . ((w:hidden_files) ? "on)\n" : "off)\n") + let ln=ln+1 | let @f=@f."\" ? = toggle long help\n" + else + let ln=ln+1 | let @f="\" ? : toggle long help\n" + endif + let w:helplines = ln + + setlocal modifiable | silent put! f | setlocal nomodifiable + + let @f=save_f +endfunction " >>> + +let &cpo = s:cpo_save + +" vim: set ts=2 sw=2 foldmethod=marker foldmarker=<<<,>>> foldlevel=2 : @@ -1,6 +1,8 @@ " bnewbold's .vimrc " circa 04/2006 +:filetype plugin on + if has('syntax') && (&t_Co > 2) syntax on endif @@ -9,12 +11,46 @@ set history=50 set wildmode=list:longest,full set showmode set showcmd -set smartcase set shiftwidth=4 set tabstop=4 set shiftround set expandtab set autoindent +set hidden + +" vtreeexplore +let treeExplVertical=1 +let treeExplWinSize=30 +let treeExplDirSort=1 +let treeExplNoList=1 +:nmap <F2> :VSTreeExplore<cr> +let g:buftabs_in_statusline=1 +let g:buftabs_only_basename=1 + +" better vertical split style +hi VertSplit cterm=none ctermfg=LightGray term=none gui=none + +" firefox style ctrl-tabbing with buffers +noremap <C-tab> :bprev<CR> +noremap <C-S-tab> :bnext<CR> +" needed for in xterm with remaping... ugh. +:nmap <Esc>[27;6;9~ :bprev<CR> +:nmap <Esc>[27;5;9~ :bnext<CR> +:map <Esc>[27;6;9~ :bprev<CR> +:map <Esc>[27;5;9~ :bnext<CR> +" and for tabbing +:nmap <C-left> :tabN<CR> +:nmap <C-right> :tabn<CR> +:map <C-left> :tabN<CR> +:map <C-right> :tabn<CR> + +" cscope quicklisting +set cscopequickfix=s-,c-,d-,i-,t-,e- + +" Searching stuff +set incsearch +set ignorecase +set smartcase autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class @@ -24,3 +60,4 @@ au BufNewFile,BufRead *.fsi,*.fss set ft=fortress " for previewing reStructured text (.rst) in firefox :command Rst :!rst2html.py "%" > /tmp/rstprev.html && firefox file:///tmp/rstprev.html :nnoremap <C-p><C-r> :Rst<CR> + |