mirror of
https://github.com/amix/vimrc
synced 2025-07-07 00:15:00 +08:00
rename vim_plugins_src to vim_plugin_candinates_src and used as an plugin candinate dir
This commit is contained in:
204
vim_plugin_candinates_src/cvim/c-support/codesnippets/Makefile
Normal file
204
vim_plugin_candinates_src/cvim/c-support/codesnippets/Makefile
Normal file
@ -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.81, April 2006,
|
||||
# section 4.13). The utility sed is used.
|
||||
#========================================== makefile template version 1.9 ======
|
||||
|
||||
# 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:
|
@ -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)
|
||||
|
@ -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 ---------- */
|
||||
|
@ -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 ---------- */
|
||||
|
20
vim_plugin_candinates_src/cvim/c-support/codesnippets/main.c
Normal file
20
vim_plugin_candinates_src/cvim/c-support/codesnippets/main.c
Normal file
@ -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 ---------- */
|
||||
|
@ -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 ----------
|
||||
|
@ -0,0 +1,28 @@
|
||||
// === FUNCTION ======================================================================
|
||||
// Name: print_array
|
||||
// Description: Print an array with one dimension.
|
||||
// Use
|
||||
// print_array<T,width,precision>( *matrix, n1*n2, n2, "matrix" );
|
||||
// for
|
||||
// T matrix[n1][n2];
|
||||
// =====================================================================================
|
||||
template < class T, unsigned width, unsigned precision >
|
||||
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(precision) << array[i];
|
||||
}
|
||||
cout << endl << endl;
|
||||
return ;
|
||||
} // ---------- end of function print_double_array ----------
|
||||
|
@ -0,0 +1,35 @@
|
||||
|
||||
/*
|
||||
* === FUNCTION ======================================================================
|
||||
* Name: print_double_array
|
||||
* Description: Print a double-array with one dimension.
|
||||
* Use
|
||||
* print_double_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, width = 8, precision = 4;
|
||||
char frmt[10];
|
||||
sprintf( frmt, " %%%d.%dlf", width, precision );
|
||||
printf ("\n\n array \"%s\", length %d\n", arrayname, n );
|
||||
printf ("\n index | content\n" );
|
||||
printf ( " ------+-" );
|
||||
for ( i = 0; i < nrow*( 1+width ); i += 1 )
|
||||
putchar('-');
|
||||
for ( i=0; i<n; i+=1 )
|
||||
{
|
||||
if( i%nrow == 0 )
|
||||
printf ("\n%6d | ", i );
|
||||
printf ( frmt, array[i] );
|
||||
}
|
||||
printf ("\n\n");
|
||||
return ;
|
||||
} /* ---------- end of function print_double_array ---------- */
|
@ -0,0 +1,36 @@
|
||||
|
||||
/*
|
||||
* === 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, width = 4;
|
||||
char frmt[10];
|
||||
sprintf( frmt, " %%%dd", width );
|
||||
printf ("\n\n array \"%s\", length %d\n", arrayname, n );
|
||||
printf ("\n index | content\n" );
|
||||
printf ( " ------+-" );
|
||||
for ( i = 0; i < nrow*( 2+width ); i += 1 )
|
||||
putchar('-');
|
||||
for ( i=0; i<n; i+=1 )
|
||||
{
|
||||
if( i%nrow == 0 )
|
||||
printf ( "\n%6d | ", i );
|
||||
printf ( frmt, array[i] );
|
||||
}
|
||||
printf ("\n\n");
|
||||
return ;
|
||||
} /* ---------- end of function print_int_array ---------- */
|
||||
|
Reference in New Issue
Block a user