Are there any cscope or ctags APIs that can be used programmatically? - ctags

I have been using ctags and cscope for sometime now. I wanted to know if there exist any APIs so as to grab output of "cscope -d". Or maybe if we can use cscope.out and tags database to extract readable information.

libreadtags is a library for reading a "tags" file generated by ctags.
If --sort=yes is specified as the command line of ctags invocation, libreadtags can do binary-search.

Related

using ctags or cscope(without interactive mode) from commandline

I am using a custom editor for an embedded systems project. For source code I would like to get ctags working from command line and give me search results on commandline. Other option is to work with cscope in non interactive mode so I can include it in my editor at a later date. I did some initial web search but couldn't find anything relevant to accomplish this.
Does anyone know how to use either of these tools from command line?? Any tutorial?
Thanks.
Have a great day.
Using readtags.c shipped as part of ctags implementation, you can search a tag from given tags file.
Let me show an example:
$ ctags -R main
$ readtags -t tags kindDefinition
kindDefinition main/types.h /^typedef struct sKindDefinition kindDefinition;$/
$ readtags -t tags -e kindDefinition
kindDefinition main/types.h /^typedef struct sKindDefinition kindDefinition;$/;" kind:t typeref:struct:sKindDefinition

ctags error "format error in tags file"

I work on c code base in Linux. I use perforce as source code repository. I had been using ctags and it was working fine. But recently when press ctrl ] in some symbol then I get below error. I removed tags file and recreated the tags file but the problem didn't solve. Any idea on how to resolve this issue?
E431: Format error in tags file "tags"
Before byte 53035586
If you are just using the ctags -R then try specifying the c language in the command like below. I had the same problem and when I specified the c language while generating the tags, the problem got resolved.
ctags -R --languages=C
There may be tags with large names in your repo. If you can live without those included in your ctags file, you can avoid this error and use rest of the ctags.
To avoid the files/folders, use this syntax
**ctags -R -V --exclude=#/path/to/ctags_ignore_file ./ **
ctags_ignore_file has the list of Folders to be excluded. You can use wildcard entries too.
This solved my problem.
TLDR; add export CSCOPE_EDITOR=vim to ~/.bashrc and close your terminal window.
In my case, setting vim as the default editor for cscope fixed the issue:
echo "export CSCOPE_EDITOR=vim" >> ~/.bashrc # Append to .bashrc
source ~/.bashrc # Load .bashrc into the current shell
After this, you may also use the following commands in your project directory for a quick reconfiguration of cscope and ctags:
ctags -R
cscope -R

couldn't execute promgen in vivado tcl

I want to generate the binary file.bin and I thought that it is possible in Vivado 2014.3 IDE
It seems like the command promgen doesn't exist?
How can I get an appropriate binary to use later in parallella board , it should have the header file
To generate a .bin file from the tcl console, the command you're looking for is write_bitstream which is documented in the Vivado Design Suite Tcl Command Reference Guide.
As #Paebbels mentioned there may be a way to use the promgen command from the command line (its not a tcl command), but I haven't ever tried that so I'm not sure. You can run the equivalent of the promgen tool (I believe PROMGen was an ISE tool) through the GUI if you connect to a device in the Hardware Manager (no longer called iMPACT in Vivado).
Finally if you need to create a .mcs file in a Tcl script you can use the write_cfgmem Tcl command (see the reference guide for more info).

ARFF file extension to csv binary executable

Thanks in advance for the help.
I'm looking for a binary executable to convert an .arff into a .csv in a bash script. Ideally something that I could run along the lines of
#! /bin/sh
... some stuff....
converstionFunc input.arff output.csv
... some more stuff ...
Looking into writing this myself I found that weka provides a library that I could utilize that would allow me to do this. However, as much as I looked for it, I could not find it. I have weka installed on my mac and after looking around for the library I still was unable to find it.
Does anyone know where I may find such an executable, or able to point me where I could get a hold of the weka java library that would let me write it myself?
Clone this github repository. It contains an arff2csv tool in the "tools" subdirectory.
arff2csv is designed to run in pipes of unix commandline tools.
https://github.com/jeroenjanssens/data-science-at-the-command-line
arff2csv is a one-line shell-script that calls another shell script that calls weka.jar,
so it needs java installed on your machine; and note that arff2csv needs Weka version 3.6. (According to my experiments the newer v3.7 does not work.)
The script wants this environment variable set:
export WEKAPATH=/path/to/wekajar-dirname
and then you can do
cat /opt/smallapps/weka-stable/data/breast-cancer.arff | arff2csv > breast-cancer.arff.csv
Large arffs need some time to get processed.
You can read J.Janssen's book (see repo-README) for a bit more info.
Try an web search for arff2csv. It looks like there are lots of utilities out there.

Providing Documentation for an Unix command?

I made an Unix command called macmac2unix, which converts a Word file from Mac to Unix.
How can I provide documentation for my command?
I want to read about my command with man
$man macmac2unix
I recommend Perl's POD format. Despite the name, you can use it outside of Perl scripts, and the pod2man command ships with OS X. It's a lot more sensible that troff. Reminds me of Markdown.
Here's an example pod document and the conversion script.
You can apparently use also DocBook to provide Documentation for an Unix command.

Resources