开源夏令营之foldcolumn工具及解决方案(七)测试与总结
来源:互联网 发布:潍坊行知2016升学率 编辑:程序博客网 时间:2024/06/07 04:57
项目地址http://code.csdn.net/os_camp/16/proposals/65
安装方法
在https://code.csdn.net/xhu_eternalcc/foldcolumn下载源码,里面有 tar/foldcolumn-xx.tar.gz,解压这个tar包:
(1)首先安装unibreak库 ,在thirdparty目录下
参考thirdparty/libunibreak-1.1/README.md
(2)安装foldcolumn库和命令行工具
cd tar
tar xzvf foldcolumn-xx.tar.gz
cd foldcolumn-xx
./configure --prefix=xxx
make
sudo make install
foldcolumn命令行工具功能与参数对应表
可以通过查看man/foldcolumn.1这个manpage或者是foldcolumn -h 来获得如下信息
foldcolumn命令行工具各功能测试
指定表格宽度
指定表格列数
指定列分割符、表格样式
指定列宽采用均分表格宽度
浮点数精度处理与右对齐
只有指定列中只包含一个数值时(不支持逗号),才会对指定进行浮点数精度处理
指定字符串开始的行不分列,指定列不换行
指定列不换行时,以此列的各行中最大列宽输出
允许包含硬回车
允许输出空行(默认是忽略空行)
格式良好的长文本流
foldcolumn库接口介绍及库样例程序
参见:库接口介绍参见开源夏令营之foldcolumn工具及解决方案(一)
#include <stdio.h>#include <stdlib.h>#include <locale.h>#include "foldcolumn.h"int main(int argc,char**argv){char**fIns=NULL;/*input files*/int fInsNum=1;/*input file number*/char*fOut=NULL;/*output files, NULL for stdout*/char mode[3]="wb";/*output mode, or ab*//*define foco_t*/foco_t fc;setlocale(LC_ALL,"");/*init foco_t*/if(foco_STATUS_OK!=foco_init(&fc)){fprintf(stderr,"init foco_t error \n");exit(EXIT_FAILURE);}/*specify input files*/if(NULL==(fIns=(char**)malloc(sizeof(char*)*fInsNum))){fprintf(stderr,"Malloc error \n");exit(EXIT_FAILURE);}fIns[0]="sample.txt";/*specify output file*/if(NULL!=fOut){if(NULL==(fc.out=fopen(fOut,mode))){fprintf(stderr,"open file %s failed\n",fOut);exit(EXIT_FAILURE);}}/*You can modify fc attributes here*///table mode ,0-3fc.table=3;//table widthfc.width=140;//column number, only print the first N columnsfc.columnSize=7;//column delimiterfc.delimiter='';//-1 for specifying column width by reading input file one time, or else will average table with into each columnfc.widthSize=-1;//fc.widths[i]=x;/*specify the first widthSize column width*///column i need to process precision, index starts from 0fc.numeric[4]=true;//percisionfc.precision=2;//alignment for column ifc.alignment[0]=foco_ALIGN_RIGHT;fc.alignment[4]=foco_ALIGN_RIGHT;//lines beginning with reg will not be broken into columns//fc.lines=reg;//column i need not to be broken into lines if possible , or else will ignore this parameter//fc.columns[i]=true;//print empty line//fc.blank=true;if(foco_STATUS_OK!=foco_foldcolumn(&fc,fIns,foco_ARGV_FN,fInsNum))fprintf(stderr,"foldcolumn execute error\n");/*destroy foco_t*/foco_destroy(&fc);if(NULL!=fOut){fclose(fc.out);free(fOut);}if(NULL!=fIns)free(fIns);return EXIT_SUCCESS;}编译运行
总结
(1)完成了所有基本功能,并对各个功能模块和整体进行了测试。
(2)时间过得真快,在foldcolumn编写期间既提高了自己的编程能力,同时也学到了很多新东西:字符编码知识、manpage的制作、automake的使用、git的使用,更重要的是从与张老师的交流中了解到了开源界的交流习惯,为以后参与开源打下了基础,在此感谢张老师的耐心指导。但是由于我个人原因,最近奔波于找工作,耽误了foldcolumn的进度,导致项目后期测试与扩展未能满足张老师的需求,打算9月底至10月继续完善foldcolumn,做到有始有终。
- 开源夏令营之foldcolumn工具及解决方案(七)测试与总结
- 开源夏令营之foldcolumn工具及解决方案(一)
- 开源夏令营之foldcolumn工具及解决方案(四)数值精度与对齐方式处理
- 开源夏令营之foldcolumn工具及解决方案(六)制作manpage与Makefile
- 开源夏令营之foldcolumn工具及解决方案之中期总结
- 开源夏令营之foldcolumn工具及解决方案(二)确定表格属性、绘制表格
- 开源夏令营之foldcolumn工具及解决方案(三)表格列超长自动换行实现
- 开源夏令营之foldcolumn工具及解决方案(五)数值精度处理实现
- 开源夏令营之foldcolumn工具及解决方案之box-drawing character
- 开源夏令营之foldcolumn工具及解决方案之获取终端宽度
- 开源夏令营之foldcolumn工具及解决方案--学习制作manpage
- 开源夏令营总结
- 开源夏令营总结
- 开源夏令营总结
- 开源夏令营总结
- 开源夏令营(9)总结
- 开源夏令营中期总结
- 开源夏令营最终总结
- 交换机和路由器分别的实现原理是什么?分别在哪个层次上面实现的?
- mysql 5.6 免安装,启动的时候存在的问题
- 程序员面试简历注意事项
- 面向对象编程的弊端
- 黑马程序员-----Hello Word!!
- 开源夏令营之foldcolumn工具及解决方案(七)测试与总结
- memset函数详细说明
- Linux 路由 学习笔记 之七 策略规则的查找
- Codeforces 362C. Insertion Sort
- C++虚函数表解析
- 多校联赛总结
- C++ 继承中的覆盖,隐藏,虚拟继承
- Python_列表和元祖
- Android - 文件操作 小结