Skip to content

Readline #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ install:
- "%PYTHON_DEF%\\python.exe ci/appveyor/fix_version.py ."
- mv -f .git .git.bak
- 7z x ci\appveyor\zlib1211.zip
- ps: ls ssh2

build_script:
- ci\\appveyor\\build_zlib.bat
- for %%I in (%PYTHONVERS%) do cp C:/zlib/lib/zlibstatic.lib %%I/libs/
- for %%I in (%PYTHONVERS%) do ls %%I/libs/
- ci\\appveyor\\build_ssh2.bat
- for %%I in (%PYTHONVERS%) do cp src/src/libssh2.lib %%I/libs/ || cp src/src/Release/libssh2.lib %%I/libs/
- mv -f ssh2/find_eol.c .
- rm -f ssh2/*.c
- mv -f find_eol.c ssh2/
- ps: ls ssh2
- for %%I in (%PYTHONVERS%) do %%I\python.exe -V
- for %%I in (%PYTHONVERS%) do %%I\python.exe setup.py build_ext
- for %%I in (%PYTHONVERS%) do %%I\python.exe setup.py build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ src
wheelhouse
.idea/
ssh2/libssh2.so*
doc/_build
9 changes: 9 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Change Log
=============

0.20.0
++++++

Changes
--------

* Added helper function ``ssh2.utils.find_eol`` for finding end of line characters in buffer.


0.19.0
+++++++

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ exclude .travis.yml
include LICENSE
include ssh2/*.pyx
include ssh2/*.pxd
include ssh2/find_eol*
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import platform
import os
import sys
Expand Down Expand Up @@ -48,7 +46,7 @@

# _comp_args = ["-ggdb"]
_fwd_default = 0
_comp_args = ["-O3"] if not ON_WINDOWS else None
_comp_args = ["-O2"] if not ON_WINDOWS else None
_embedded_lib = bool(int(os.environ.get('EMBEDDED_LIB', 1)))
_have_agent_fwd = bool(int(os.environ.get('HAVE_AGENT_FWD', _fwd_default)))

Expand Down Expand Up @@ -87,6 +85,10 @@
)
for i in range(len(sources))]

for ext in extensions:
if ext.name == 'ssh2.utils':
ext.sources.append('ssh2/find_eol.c')

package_data = {'ssh2': ['*.pxd', 'libssh2.so*']}

if ON_WINDOWS:
Expand Down
38 changes: 38 additions & 0 deletions ssh2/find_eol.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
This file is part of ssh2-python.
Copyright (C) 2017-2020 Panos Kittenis

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, version 2.1.

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <string.h>

static int CR = '\r';
static int EOL = '\n';

int find_eol(char* data, int* new_pos) {
unsigned int index;
char *found;
found = strchr(data, EOL);
if (found == NULL) {
return -1;
}
if (strchr(found-1, CR)) {
found--;
++*new_pos;
}
index = found - data;
++*new_pos;
return index;
}
19 changes: 19 additions & 0 deletions ssh2/find_eol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
This file is part of ssh2-python.
Copyright (C) 2017-2020 Panos Kittenis

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, version 2.1.

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

int find_eol(char* data, int* new_pos);
Loading