⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wpw_wapi_misc_95.html

📁 VC programing
💻 HTML
📖 第 1 页 / 共 2 页
字号:
and regerror.o into your C library, and regexp.3 into your manual-pages
directory.

Note that if you don't put regexp.h into /usr/include *before* compiling,
you'll have to add "-I." to CFLAGS before compiling.

The files are:

Makefile        instructions to make everything
regexp.3        manual page
regexp.h        header file, for /usr/include
regexp.c        source for regcomp() and regexec()
regsub.c        source for regsub()
regerror.c      source for default regerror()
regmagic.h      internal header file
try.c           source for test program
timer.c         source for timing program
tests           test list for try and timer

This implementation uses nondeterministic automata rather than the
deterministic ones found in some other implementations, which makes it
simpler, smaller, and faster at compiling regular expressions, but slower
at executing them.  In theory, anyway.  This implementation does employ
some special-case optimizations to make the simpler cases (which do make
up the bulk of regular expressions actually used) run quickly.  In general,
if you want blazing speed you're in the wrong place.  Replacing the insides
of egrep with this stuff is probably a mistake; if you want your own egrep
you're going to have to do a lot more work.  But if you want to use regular
expressions a little bit in something else, you're in luck.  Note that many
existing text editors use nondeterministic regular-expression implementations,
so you're in good company.

This stuff should be pretty portable, given appropriate option settings.
If your chars have less than 8 bits, you're going to have to change the
internal representation of the automaton, although knowledge of the details
of this is fairly localized.  There are no "reserved" char values except for
NUL, and no special significance is attached to the top bit of chars.
The string(3) functions are used a fair bit, on the grounds that they are
probably faster than coding the operations in line.  Some attempts at code
tuning have been made, but this is invariably a bit machine-specific.
-- 
Steve Tell       tell@cs.unc.edu        W: +1 919 962 1845
Research Associate, Computer Science Department, UNC@Chapel Hill.   
Who needs 3-D television when you've got live theatre? -me
<HR>
On Tue, 20 Jun 1995, Gopher client wrote:

> I am trying to put a regular expression search menu on my windows 
> application. However, there seems no regular expression library in
> Visual C++ or Borland C++ (Am I right?). So I need to build one.
> Actually, I don't need a library, I only need a matching or searching
> function like the string searching one. Certainly this will include 
> the compilation routine which converts input string to internal
> regular expression representation.

Look up MATCH.H and MATCH.C in SNIPPETS.

-------------------------------------------------------------
MicroFirm: Down to the C in chips...
FidoNet 1:106/2000.6
Internet bobstout@neosoft.com
Home of SNIPPETS - Current release:
        oak.oakland.edu:/SimTel/msdos/c/snip9503.zip
        juge.com:/c/file/c/snip9503.lzh

<HR>
In article <Pine.BSD.3.91.950623014739.22763D-100000@starbase.neosoft.com>,
Bob Stout  <bobstout@neosoft.com> wrote:
>On Tue, 20 Jun 1995, Gopher client wrote:
>
>> I am trying to put a regular expression search menu on my windows 
>> application. However, there seems no regular expression library in
>> Visual C++ or Borland C++ (Am I right?). So I need to build one.
>> Actually, I don't need a library, I only need a matching or searching
>> function like the string searching one. Certainly this will include 
>> the compilation routine which converts input string to internal
>> regular expression representation.
>
>Look up MATCH.H and MATCH.C in SNIPPETS.
>
>
you might also look for a C++ class library called strpp that's on
compuserve, and possible simtel. it does an excellent job of providing regex
and AWK style functions with string handling capability.


-- 
Mike Lottridge
Applications Engineering, Lattice Semiconductor
email:        mikelo@netcom.com 
office phone: (800)327-8425/(503)693-0219
voice mail:   (800)870 4270 mailbox 219
fax:          (503)681-3037
mailing address: Lattice Semiconductor
                 5555 N.E. Moore Ct.
                 Hillsboro, OR 97124


</PRE>


<HR><A NAME=WINAPI_MISC_CALL_FORTRAN>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Calling fortran from C</H4><PRE>
A friend of mine has a problem calling fortran routines from C programs
using Visual C++ 2.0.
He has included the fortran .obj file in the make file and declares
the fortran function as extern __stdcal (he also tried cdecl) in the C module.
When he then uses the function he gets an undefined symbol error during
link.
Does anyone know how to successfully use fortran functions in C ?

--
Knut Radloff    *    knut@krhh.hanse.de    *    voice & fax: ++49-40-8119484

<HR>
In article <3rvl1v$h4t@popcorn.hamburg.pop.de> knut@krhh.hanse.de  writes:

>A friend of mine has a problem calling fortran routines from C programs
>using Visual C++ 2.0.
>He has included the fortran .obj file in the make file and declares
>the fortran function as extern __stdcal (he also tried cdecl) in the C module.
>When he then uses the function he gets an undefined symbol error during
>link.
>Does anyone know how to successfully use fortran functions in C ?

Assuming he's using a suitable FORTRAN compiler (eg Microsoft's FORTRAN
PowerStation compiler) it should be no problem at all. If he's really using
C, just call the function as normal. If he's using C++, he'll obviously need
to take the "name mangling" into account.

Chris
-- 
--------------------------------------------------------------------------
| Chris Marriott, Warrington, UK      | Author of SkyMap v2 shareware    |
| chris@chrism.demon.co.uk            | astronomy program for Windows.   |
|      For more info, see http://www.winternet.com/~jasc/skymap.html     |
|      Author member of Association of Shareware Professionals (ASP)     |
--------------------------------------------------------------------------
 
 <HR>
 In article <3rvl1v$h4t@popcorn.hamburg.pop.de> knut@krhh.hanse.de  writes:

> A friend of mine has a problem calling fortran routines from C programs
> using Visual C++ 2.0.
> He has included the fortran .obj file in the make file and declares
> the fortran function as extern __stdcal (he also tried cdecl) in the C module.
> When he then uses the function he gets an undefined symbol error during
> link.
> Does anyone know how to successfully use fortran functions in C ?

I declare them as PASCAL.  (cdecl is definitely wrong; don't know about
 __stdcal).

(C and FORTRAN pass their arguments in the opposite order.)

The other thing is that standard FORTRAN passes by reference.  Therefore
you have to pass pointers.

    INTEGER*4    <=>   long  *
    INTEGER*2    <=>   short *

Passing strings is harder.  I usually check a string passed into
FORTRAN looking for the '\0' and make a copy of it before doing anything.
FORTRAN keeps info about variable length strings in the few bytes BEFORE
the start of the string - so be very careful.

Hope this enables you to make progress.  (BTW I assume you are using the
Microsoft 32 bit FORTRAN compiler - I have actually only done it with
the 16 bit compilers but it should be easier in 32 - I think!)

Dave
-- 
+---------------------------+-----------------------------------+
| Dave Webber                        dave@musical.demon.co.uk   |
| Author of MOZART, the Windows 3.1 shareware Music Processor   |
| and member of the Association of Shareware Professionals      |
+---------------------------+-----------------------------------+

 </PRE>
 

<HR><A NAME=WINAPI_MISC_FLOAT_TO_STRING>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Place Floating Point in a String</H4><PRE>
Jeffrey N Woodford (jwoodfor@unlinfo.unl.edu) wrote:
: Nicholas A Charsley (Nick@chells.demon.co.uk) wrote:
: : As the Subject says, I want to print out a string containing a floating 
: : point decimal, normaly I would just use sprintf(...,"%f",....), but for 
: : reasons known only to microsoft they don't allow sprintf in DLL's, and 
: : thier replacement wsprintf() won't print floats!

Separate the fractions (i.e 123.456 is two integers 123 and 456) and then
print them with %d.%d

Riho
<HR>

In article <3s3788$m7f@apc.crebit.ee> rihoe@news.crebit.ee writes:

> Jeffrey N Woodford (jwoodfor@unlinfo.unl.edu) wrote:
> : Nicholas A Charsley (Nick@chells.demon.co.uk) wrote:
> : : As the Subject says, I want to print out a string containing a floating 
> : : point decimal, normaly I would just use sprintf(...,"%f",....), but for 
> : : reasons known only to microsoft they don't allow sprintf in DLL's, and 
> : : thier replacement wsprintf() won't print floats!
> 
> Separate the fractions (i.e 123.456 is two integers 123 and 456) and then
> print them with %d.%d
> 
> Riho
> 

In VC++ there are functions available to handle float-to-string conversion in
a DLL! They are the C run-time functions _ecvt() and _fcvt(), and will work
correctly in code built with all memory models.

I don't know if they exist in other compilers!

I hope this helps Nicholas :-)

Regards,

    Jonnathon.
-- 
<HR>

In article <391137475wnr@chells.demon.co.uk>
           Nick@chells.demon.co.uk "Nicholas A Charsley" writes:

> As the Subject says, I want to print out a string containing a floating 
> point decimal, normaly I would just use sprintf(...,"%f",....), but for 
> reasons known only to microsoft they don't allow sprintf in DLL's, and 
> thier replacement wsprintf() won't print floats!
> 
> Does anyone have any soloutions to this problem? 

Good news.  sprintf() works fine in DLL's - I think it became ok in
VC++ 1.5 but thet didn't shout about it.

If you have MFC version 3 then CString.Format() might work too.  The
documentation seems to imply it will, but I've not tried it.

Dave
-- 
+---------------------------+-----------------------------------+
| Dave Webber                        dave@musical.demon.co.uk   |
| Author of MOZART, the Windows 3.1 shareware Music Processor   |
| and member of the Association of Shareware Professionals      |
+---------------------------+-----------------------------------+
<HR>
Simply use sprintf() to print your floats into a string, then 
do what you will with the string.  Example:
char lpszBuffer[60];
sprintf(lpszBuffer,"%f",3.354432);
SetWindowText(hwnd,lpszBuffer);

>       Alot of my projects used floating point numbers, but I have found 
>that you have to convert them to INTs before windows will print the 
>numbers.  Is there a way in Borland 3.0 for Windows that will let you 
>print floating point variables?  If the routine is there and I hhave 
>missed it, could you please send the name of the routine.

-----------------------------------------------------------
Daniel G. Hyams
email:  dhyams@eng.clemson.edu
WWW:    http://www.eng.clemson.edu/~dhyams/
phone:  (803) 639-4722
-----------------------------------------------------------
</PRE>



<HR><A NAME=WINAPI_MISC_CALLBACK_PROC_CPP>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Using Call Back PROC in C++</H4><PRE>
I'd like to get an explanation of the use of CALLBACK functions within a
C++ class, but I don't want an OWL or MFC solution.  I just want to deal
with raw C++ so I can understand how it works.

So let's say I write a C++ class that needs a WndProc or DlgProc, i.e. for
a toolbar, % done dialog or for subclassing a control. I understand that
C++ member functions have the extra argument 'this' to all of the member
functions, therefore a CALLBACK function can not be part of a C++ class.
Ok, so then what is it supposed to be - just an ordinary CALLBACK function
outside of the class?  If so, that means I should use the CREATEITEMSTRUCT
(CreateWindow) or the equivalent DialogBoxParam to ensure that the function
is re-entrant, right? But there's no way to encapsulate it in the class...

Are there any other issues?  I seem to recall a reference to an article at
ftp.microsoft.com regarding a somewhat kludged solution to this problem.
I couldn't find the article in the index - can anyone point me to it?
Is the solution still relevant?
-- 
John A. Grant                                           jagrant@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa
<HR>

John Grant (jagrant@emr1.emr.ca) wrote:
> I'd like to get an explanation of the use of CALLBACK functions within a
> C++ class, but I don't want an OWL or MFC solution.  I just want to deal
> with raw C++ so I can understand how it works.

The problem with tring to supply c++ member functions as callbacks is,
as you have no doubt discovered, the need to pass round the "this"
pointer as the first argument.

There are a number of contrived workarounds, but most use the same
technique of having a static member function which somehow decides
which non-static member function to dispatch the call to.

The hard part is now : how do you tell which instance to pass the
callback to? Various techniques include
        -add some extra bytes to each window
        -maintain a table mapping windows or other handles to classes
        -have a static pointer in the class to point to the member
         you want the next callback to be passed to.
        -Use the extra DWORD which many callbacks provide to pass the
         pointer around.

The final option is becoming easier as more API extentions are
explicity adding an extra dword of unintepreted data to be returned to
the callback with all the other guff. -See the WINSOCK 2 API spec for
examples of this.

If you want the ultimate no-holds-barred performance, then you can
write your own equivalent MakeProcInstance. Remember how in the Elder
Days of windows progamming you used to have to call MakeProcInstance on
all exported functions, which wrote a small stub thunk to ensure
that the individual instance of an app got called by doing something like
        
mov DS,this-hInstance
jmp FAR callbackproc

Now since Mike Geary pointed out that mov DS,SS usually works in
standard and enhance mode apps this call has gone out favour. But you
can do the same thing for c++ classes -especially if you use the
_fastthis calling convention (the this pointer is passed in registers)
with something like

mov DS,HIWORD(this)
mov SI,HIWORD(this)
jmp FAR callbackproc

Of course, you are going to have to write code on the fly to do this,
and learn all about PrestoChangoSelect

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -